#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n;
set<pair<long long int, long long int> > S[2];
vector<pair<long long int, long long int> > res;
pair<long long int, long long int> get(pair<long long int, long long int> a,
                                       pair<long long int, long long int> b) {
  if (b.first < a.first) swap(a.first, b.first);
  if (a.second >= b.second) return a;
  long long int cm = 0;
  while ((a.first & (1LL << (31 - cm))) == (b.second & (1LL << (31 - cm))))
    ++cm;
  a.first >>= 32 - cm;
  a.first <<= 32 - cm;
  return {a.first, a.first + (1LL << (32 - cm)) - 1};
}
void add(int t, pair<long long int, long long int> a) {
  while (S[t].size()) {
    auto it = S[t].lower_bound(a);
    if (it != S[t].end() && (*it).first <= a.second + 1) {
      a.second = max(a.second, (*it).second);
      S[t].erase(it);
      continue;
    }
    if (it != S[t].begin()) {
      --it;
      if ((*it).second >= a.first) {
        a.first = (*it).first;
        a.second = max(a.second, (*it).second);
        S[t].erase(it);
        continue;
      }
    }
    break;
  }
  S[t].insert(a);
}
void read() {
  string s;
  cin >> s;
  int t = s[0] == '+' ? 1 : 0;
  long long int p = 0LL, k = 1;
  int lst = s.size();
  for (int i = 0; i < s.size(); ++i)
    if (s[i] == '/') {
      long long int x = 0;
      for (int j = i + 1; j < s.size(); ++j) x *= 10, x += s[j] - '0';
      lst = i;
      k = 1LL << (32 - x);
      break;
    }
  for (int i = 1; i < s.size(); ++i) {
    int nxt = lst;
    for (int j = i; j < nxt; ++j)
      if (s[j] == '.') {
        nxt = j;
        break;
      }
    long long int cur = 0LL;
    for (int j = i; j < nxt; ++j) cur *= 10, cur += s[j] - '0';
    p += cur;
    if (nxt < lst)
      p *= 256;
    else
      break;
    i = nxt;
  }
  if (t == 1)
    add(t, {p, p + k - 1});
  else
    S[t].insert({p, p + k - 1});
}
bool check(pair<long long int, long long int> a) {
  if (S[1].size() == 0) return true;
  auto it = S[1].lower_bound(a);
  if (it != S[1].end() && (*it).first <= a.second) return false;
  if (it != S[1].begin() && (*(--it)).second >= a.first) return false;
  return true;
}
void write(pair<long long int, long long int> a) {
  a.second -= a.first - 1;
  int pt = 0;
  while ((1LL << pt) < a.second) ++pt;
  printf("%lld.%lld.%lld.%lld/%d\n", a.first / (1 << 24),
         (a.first % (1 << 24)) / (1 << 16), (a.first % (1 << 16)) / (1 << 8),
         a.first % (1 << 8), 32 - pt);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) read();
  for (auto v : S[0])
    if (!check(v)) {
      puts("-1");
      return 0;
    }
  pair<long long int, long long int> last = *S[0].begin();
  S[0].erase(S[0].begin());
  while (S[0].size()) {
    if (check(get(last, *S[0].begin())))
      last = get(last, *S[0].begin());
    else {
      res.push_back(last);
      last = *S[0].begin();
    }
    S[0].erase(S[0].begin());
  }
  res.push_back(last);
  printf("%d\n", res.size());
  for (auto v : res) write(v);
  return 0;
}
