#include<bits/stdc++.h>
#define N 100010
#define LL unsigned int
using namespace std;
int n,m=0;
char x[30];
vector<int> th;
bool f[N];
struct node
{
LL a;int b,c;
bool operator < (const node z) const
{
return a==z.a?b<z.b:a<z.a;
}
}c[N];
int pp(char *s)
{
th.clear();
int t=-1;
for (int i=0;s[i];i++)
{
if (s[i]=='.') th.push_back(i);
if (s[i]=='/') t=i;
}
return t;
}
void pre(char *s)
{
int fg=pp(s),b;
LL a=0;
if (fg>0) b=atoi(s+fg+1),s[fg]=0;else
b=(1+th.size())*8;
int st=-1;
for (int i=0;i<=th.size();i++)
{
int x=atoi(s+st+1);
a=a+((LL)x<<((3-i)*8));
if (th.size()>i) st=th[i];
}
c[++m]=node{a,b,32-b};
}
void pri(node c)
{
LL a=c.a;
printf("%d.%d.%d.%d/%d\n",a>>24,(a>>16)%256,(a>>8)%256,a%256,c.b);
}
int main()
{
scanf("%d ",&n);
for (int i=1;i<=n;i++)
{
scanf("%s",x);
pre(x);
}
sort(c+1,c+n+1);
int st=1;
for (int i=2;i<=n;i++)
{
if (c[st].b<=c[i].b && (c[st].a>>c[st].c)==(c[i].a>>c[st].c)) f[i]=true;else
st=i;
}
stack<node> sta,stb;
for (int i=n;i>0;i--) if (!f[i]) stb.push(c[i]);
while(!stb.empty())
{
if (sta.empty())
{
sta.push(stb.top());
stb.pop();
}else
{
node a=sta.top(),b=stb.top();
if (a.b==b.b && (b.a>>b.c)-(a.a>>a.c)==1 && (b.a>>b.c+1)==(a.a>>a.c+1))
{
sta.pop();
stb.pop();
stb.push(node{a.a,a.b-1,a.c+1});
}else
{
sta.push(b);
stb.pop();
}
}
}
vector<node>ans;
while(!sta.empty())
{
ans.push_back(sta.top());
sta.pop();
}
sort(ans.begin(),ans.end());
for (int i=0;i<ans.size();i++)pri(ans[i]);
}