#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__)
#else
#define DEBUG(...) 6
#endif
template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << "\033[1;35m" << s << "\033[0;32m = \033[33m" << x << "\033[0m\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {for (int i=0, b=0; i<(int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++; else
if (s[i] == ')' || s[i] == '}') b--; else if (s[i] == ',' && b == 0) {cerr << "\033[1;35m" << s.substr(0, i) << "\033[0;32m = \033[33m" << x << "\033[31m | "; debug(s.substr(s.find_first_not_of(' ', i + 1)), args...); break;}}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<array<int, 2>> trie(1);
vector<int> cnt(1);
for (int i=0; i<n; i++) {
string s;
cin >> s;
uint32_t val = 0;
int last = 0;
for (int j=0; j<(int)s.size(); j++)
if (s[j] == '.' || s[j] == '/') {
val = (val << 8) + stoi(s.substr(last, j - last));
last = j + 1;
}
int u = 0, len = stoi(s.substr(s.find('/') + 1));
for (int j=31; j>=0 && len>0; j--, len--) {
int b = val >> j & 1;
if (!trie[u][b]) {
trie[u][b] = (int) trie.size();
trie.emplace_back();
cnt.emplace_back();
}
u = trie[u][b];
}
cnt[u]++;
}
auto dfs1 = [&] (auto &self, int u, int len, uint32_t val) -> void {
if (u == 0 && len > 0)
return;
self(self, trie[u][0], len + 1, val << 1);
self(self, trie[u][1], len + 1, (val << 1) + 1);
if (cnt[trie[u][0]] > 0 && cnt[trie[u][1]] > 0)
cnt[u]++;
};
auto dfs2 = [&] (auto &self, int u, int len, uint32_t val) -> void {
if (u == 0 && len > 0)
return;
if (cnt[u] > 0) {
uint32_t cur = val << (32 - len);
string ret = '/' + to_string(len);
for (int rep=0; rep<4; rep++) {
ret = '.' + to_string(cur % 256) + ret;
cur >>= 8;
}
cout << ret.substr(1) << "\n";
return;
}
self(self, trie[u][0], len + 1, val << 1);
self(self, trie[u][1], len + 1, (val << 1) + 1);
};
dfs1(dfs1, 0, 0, 0);
dfs2(dfs2, 0, 0, 0);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojaWZkZWYgTE9DQUwKI2RlZmluZSBERUJVRyguLi4pIGRlYnVnKCNfX1ZBX0FSR1NfXywgX19WQV9BUkdTX18pCiNlbHNlCiNkZWZpbmUgREVCVUcoLi4uKSA2CiNlbmRpZgoKdGVtcGxhdGU8dHlwZW5hbWUgVCwgdHlwZW5hbWUgUz4gb3N0cmVhbSYgb3BlcmF0b3IgPDwgKG9zdHJlYW0gJm9zLCBjb25zdCBwYWlyPFQsIFM+ICZwKSB7cmV0dXJuIG9zIDw8ICIoIiA8PCBwLmZpcnN0IDw8ICIsICIgPDwgcC5zZWNvbmQgPDwgIikiO30KdGVtcGxhdGU8dHlwZW5hbWUgQywgdHlwZW5hbWUgVCA9IGRlY2F5PGRlY2x0eXBlKCpiZWdpbihkZWNsdmFsPEM+KCkpKT4sIHR5cGVuYW1lIGVuYWJsZV9pZjwhaXNfc2FtZTxDLCBzdHJpbmc+Ojp2YWx1ZT46OnR5cGUqID0gbnVsbHB0cj4Kb3N0cmVhbSYgb3BlcmF0b3IgPDwgKG9zdHJlYW0gJm9zLCBjb25zdCBDICZjKSB7Ym9vbCBmID0gdHJ1ZTsgb3MgPDwgIlsiOyBmb3IgKGNvbnN0IGF1dG8gJnggOiBjKSB7aWYgKCFmKSBvcyA8PCAiLCAiOyBmID0gZmFsc2U7IG9zIDw8IHg7fSByZXR1c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qPChpbnQpcy5zaXplKCk7IGorKykKICAgICAgICAgICAgaWYgKHNbal0gPT0gJy4nIHx8IHNbal0gPT0gJy8nKSB7CiAgICAgICAgICAgICAgICB2YWwgPSAodmFsIDw8IDgpICsgc3RvaShzLnN1YnN0cihsYXN0LCBqIC0gbGFzdCkpOwogICAgICAgICAgICAgICAgbGFzdCA9IGogKyAxOwogICAgICAgICAgICB9CiAgICAgICAgaW50IHUgPSAwLCBsZW4gPSBzdG9pKHMuc3Vic3RyKHMuZmluZCgnLycpICsgMSkpOwogICAgICAgIGZvciAoaW50IGo9MzE7IGo+PTAgJiYgbGVuPjA7IGotLSwgbGVuLS0pIHsKICAgICAgICAgICAgaW50IGIgPSB2YWwgPj4gaiAmIDE7CiAgICAgICAgICAgIGlmICghdHJpZVt1XVtiXSkgewogICAgICAgICAgICAgICAgdHJpZVt1XVtiXSA9IChpbnQpIHRyaWUuc2l6ZSgpOwogICAgICAgICAgICAgICAgdHJpZS5lbXBsYWNlX2JhY2soKTsKICAgICAgICAgICAgICAgIGNudC5lbXBsYWNlX2JhY2soKTsKICAgICAgICAgICAgfQogICAgICAgICAgICB1ID0gdHJpZVt1XVtiXTsKICAgICAgICB9CiAgICAgICAgY250W3VdKys7CiAgICB9CgogICAgYXV0byBkZnMxID0gWyZdIChhdXRvICZzZWxmLCBpbnQgdSwgaW50IGxlbiwgdWludDMyX3QgdmFsKSAtPiB2b2lkIHsKICAgICAgICBpZiAodSA9PSAwICYmIGxlbiA+IDApCiAgICAgICAgICAgIHJldHVybjsKICAgICAgICBzZWxmKHNlbGYsIHRyaWVbdV1bMF0sIGxlbiArIDEsIHZhbCA8PCAxKTsKICAgICAgICBzZWxmKHNlbGYsIHRyaWVbdV1bMV0sIGxlbiArIDEsICh2YWwgPDwgMSkgKyAxKTsKICAgICAgICBpZiAoY250W3RyaWVbdV1bMF1dID4gMCAmJiBjbnRbdHJpZVt1XVsxXV0gPiAwKQogICAgICAgICAgICBjbnRbdV0rKzsKICAgIH07CgogICAgYXV0byBkZnMyID0gWyZdIChhdXRvICZzZWxmLCBpbnQgdSwgaW50IGxlbiwgdWludDMyX3QgdmFsKSAtPiB2b2lkIHsKICAgICAgICBpZiAodSA9PSAwICYmIGxlbiA+IDApCiAgICAgICAgICAgIHJldHVybjsKICAgICAgICBpZiAoY250W3VdID4gMCkgewogICAgICAgICAgICB1aW50MzJfdCBjdXIgPSB2YWwgPDwgKDMyIC0gbGVuKTsKICAgICAgICAgICAgc3RyaW5nIHJldCA9ICcvJyArIHRvX3N0cmluZyhsZW4pOwogICAgICAgICAgICBmb3IgKGludCByZXA9MDsgcmVwPDQ7IHJlcCsrKSB7CiAgICAgICAgICAgICAgICByZXQgPSAnLicgKyB0b19zdHJpbmcoY3VyICUgMjU2KSArIHJldDsKICAgICAgICAgICAgICAgIGN1ciA+Pj0gODsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb3V0IDw8IHJldC5zdWJzdHIoMSkgPDwgIlxuIjsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBzZWxmKHNlbGYsIHRyaWVbdV1bMF0sIGxlbiArIDEsIHZhbCA8PCAxKTsKICAgICAgICBzZWxmKHNlbGYsIHRyaWVbdV1bMV0sIGxlbiArIDEsICh2YWwgPDwgMSkgKyAxKTsKICAgIH07CgogICAgZGZzMShkZnMxLCAwLCAwLCAwKTsKICAgIGRmczIoZGZzMiwgMCwgMCwgMCk7CgogICAgcmV0dXJuIDA7Cn0K