#include <bits/stdc++.h>
using namespace std;
long long n;
bool impossible;
set<long long> blacklist[33], whitelist[33];
void solve() {
  scanf("%lld\n", &n);
  for (long long i = 0; i < n; i++) {
    long long a, b, c, d = 0, first = 0;
    char ch;
    char s[11];
    scanf("%c%lld.%lld.%lld.%s\n", &ch, &a, &b, &c, s);
    long long l = strlen(s);
    long long flag = 0;
    for (long long j = 0; j < l; j++) {
      if (s[j] == '/') {
        flag = 1;
        continue;
      }
      if (flag)
        first = first * 10 + s[j] - '0';
      else
        d = d * 10 + s[j] - '0';
    }
    if (flag == 0) first = 32;
    long long mask = (a << 24) + (b << 16) + (c << 8) + d;
    if (ch == '-')
      blacklist[first].insert(mask >> (32 - first));
    else
      whitelist[first].insert(mask >> (32 - first));
  }
  for (long long i = 0; i < 33; i++) {
    for (auto j : blacklist[i]) {
      for (long long k = 0; k < i + 1; k++) {
        if (whitelist[i - k].count(j >> k)) {
          cout << -1 << '\n';
          return;
        }
      }
    }
  }
  for (long long i = 0; i < 33; i++) {
    for (auto j : whitelist[i]) {
      for (long long k = 0; k < i + 1; k++) {
        if (blacklist[i - k].count(j >> k)) {
          cout << -1 << '\n';
          return;
        }
      }
    }
  }
  vector<pair<long long, long long> > ans;
  for (long long i = 32; i >= 0; i--) {
    vector<long long> v((blacklist[i]).begin(), (blacklist[i]).end());
    for (auto j : v) {
      for (long long k = 0; k < i; k++) {
        if (blacklist[k].count(j >> (i - k))) {
          blacklist[i].erase(j);
          break;
        }
      }
    }
    vector<long long> vv((blacklist[i]).begin(), (blacklist[i]).end());
    for (auto j : v) {
      if (i and whitelist[i].count(j) == 0 and whitelist[i].count(j ^ 1) == 0) {
        if (blacklist[i].count(j)) blacklist[i].erase(j);
        if (blacklist[i].count(j ^ 1)) blacklist[i].erase(j ^ 1);
        blacklist[i - 1].insert(j >> 1);
      }
    }
    for (auto j : blacklist[i]) {
      ans.push_back({j << (32 - i), i});
    }
    for (auto j : whitelist[i]) {
      if (i) whitelist[i - 1].insert(j >> 1);
    }
  }
  cout << (long long)ans.size() << '\n';
  for (auto i : ans) {
    long long cur = i.first;
    long long d = cur % 256;
    cur /= 256;
    long long c = cur % 256;
    cur /= 256;
    long long b = cur % 256;
    cur /= 256;
    long long a = cur % 256;
    cur /= 256;
    cout << a << "." << b << "." << c << "." << d << "/" << i.second << '\n';
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
