#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
tuple<bool, unsigned, int> parse(string& second) {
  bool neg = second[0] == '-';
  vector<unsigned> v(4, 0);
  unsigned at = 0, idx = 0;
  for (int i = 1; i < second.size(); i++) {
    if (second[i] == '/') break;
    if (second[i] == '.') {
      v[idx++] = at;
      at = 0;
      continue;
    }
    at = 10 * at + second[i] - '0';
  }
  v[idx] = at;
  int len = 0;
  int pos = -1;
  for (int i = 0; i < second.size(); i++)
    if (second[i] == '/') pos = i;
  if (pos + 1) {
    at = 0;
    for (int i = pos + 1; i < second.size(); i++)
      at = 10 * at + second[i] - '0';
    len = 32 - at;
  }
  return {neg, v[0] * (1u << 24) + v[1] * (1u << 16) + v[2] * (1u << 8) + v[3],
          len};
}
void printa(pair<unsigned, int> val) {
  auto [ip, len] = val;
  vector<unsigned> v;
  for (int i = 0; i < 4; i++) {
    v.push_back(ip & ((1 << 8) - 1));
    ip >>= 8;
  }
  reverse(v.begin(), v.end());
  for (int i = 0; i < 4; i++) {
    if (i) cout << '.';
    cout << v[i];
  }
  if (len > 0) cout << '/' << 32 - len;
  cout << '\n';
}
const int MAX = (2e5) * 32 + 10;
int trie[MAX][2];
int cnt;
int mais[MAX], menos[MAX];
int sub_mais[MAX], sub_menos[MAX];
void insert(unsigned mask, bool neg, int len) {
  int at = 0;
  for (int i = 31; i >= len; i--) {
    if (!trie[at][mask >> i & 1]) trie[at][mask >> i & 1] = ++cnt;
    at = trie[at][mask >> i & 1];
  }
  if (neg)
    menos[at]++;
  else
    mais[at]++;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string second;
    cin >> second;
    auto [neg, mask, len] = parse(second);
    insert(mask, neg, len);
  }
  for (int i = cnt; i + 1; i--) {
    sub_mais[i] = mais[i] + sub_mais[trie[i][0]] + sub_mais[trie[i][1]];
    sub_menos[i] = menos[i] + sub_menos[trie[i][0]] + sub_menos[trie[i][1]];
    if ((mais[i] and sub_menos[i]) or (menos[i] and sub_mais[i]))
      return cout << -1 << '\n', 0;
  }
  vector<pair<unsigned, int>> ans;
  queue<tuple<int, unsigned, int>> q;
  q.emplace(0, 0, 32);
  while (q.size()) {
    auto [id, mask, bit] = q.front();
    q.pop();
    if (sub_menos[id] and !sub_mais[id])
      ans.emplace_back(mask, bit);
    else {
      if (trie[id][0]) q.emplace(trie[id][0], mask, bit - 1);
      if (trie[id][1])
        q.emplace(trie[id][1], mask | (1u << (bit - 1)), bit - 1);
    }
  }
  cout << ans.size() << '\n';
  for (auto i : ans) printa(i);
  return 0;
}
