#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9;
const long long INFF = (long long)1e18;
const int mod = (int)1e9 + 7;
const int MXN = (int)1e5 + 7;
char buf[MXN];
long long val[5];
set<pair<long long, long long> > st1, st2, used;
set<long long> st3;
long long bs[33];
void sol() {
  for (pair<long long, long long> x : st2) {
    long long v1 = x.first, v2 = x.second;
    long long ll = v1, rr = v2, t = __builtin_popcountll(v2 - v1);
    int ok = 0;
    for (int i = t; i < 33; ++i) {
      ll = v1 & ((bs[32] - 1) ^ (bs[i] - 1));
      rr = ll + bs[i] - 1;
      if (used.count(make_pair(ll, rr))) {
        ok = 1;
        break;
      }
    }
    if (ok) continue;
    long long l = -1, r = -1;
    for (int i = t; i < 33; ++i) {
      ll = v1 & ((bs[32] - 1) ^ (bs[i] - 1));
      rr = ll + bs[i] - 1;
      if (st1.count(make_pair(ll, rr))) {
        puts("-1");
        exit(0);
      }
    }
    for (int i = t; i < 33; ++i) {
      ll = v1 & ((bs[32] - 1) ^ (bs[i] - 1));
      rr = ll + bs[i] - 1;
      auto it = st3.lower_bound(ll);
      if (it != st3.end() && *it <= rr) break;
      auto it2 = st1.lower_bound(make_pair(ll, rr));
      if (it2 != st1.end() && it2->first <= rr) break;
      l = ll, r = rr;
    }
    if (l == -1) {
      puts("-1");
      exit(0);
    }
    used.insert(make_pair(l, r));
  }
  return;
}
int main(void) {
  bs[0] = 1;
  for (int i = 1; i < 33; ++i) bs[i] = bs[i - 1] << 1;
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n + 1; ++i) {
    scanf("%s", buf);
    int l = strlen(buf);
    if (buf[0] == '+') {
      bool ck = 0;
      for (int i = l - 1; i >= 0; --i)
        if (buf[i] == '/') {
          ck = 1;
          break;
        }
      if (ck) {
        sscanf(buf, "+%lld.%lld.%lld.%lld/%lld", val, val + 1, val + 2, val + 3,
               val + 4);
        long long v = 0;
        for (int j = 0; j < 4; ++j) {
          v <<= 8;
          v |= val[j];
        }
        st1.insert(make_pair(v, v | (bs[32 - val[4]] - 1)));
        st3.insert(v | (bs[32 - val[4]] - 1));
      } else {
        sscanf(buf, "+%lld.%lld.%lld.%lld", val, val + 1, val + 2, val + 3);
        long long v = 0;
        for (int j = 0; j < 4; ++j) {
          v <<= 8;
          v |= val[j];
        }
        st1.insert(make_pair(v, v));
        st3.insert(v);
      }
    } else {
      bool ck = 0;
      for (int i = l - 1; i >= 0; --i)
        if (buf[i] == '/') {
          ck = 1;
          break;
        }
      if (ck) {
        sscanf(buf, "-%lld.%lld.%lld.%lld/%lld", val, val + 1, val + 2, val + 3,
               val + 4);
        long long v = 0;
        for (int j = 0; j < 4; ++j) {
          v <<= 8;
          v |= val[j];
        }
        st2.insert(make_pair(v, v | (bs[32 - val[4]] - 1)));
      } else {
        sscanf(buf, "-%lld.%lld.%lld.%lld", val, val + 1, val + 2, val + 3);
        long long v = 0;
        for (int j = 0; j < 4; ++j) {
          v <<= 8;
          v |= val[j];
        }
        st2.insert(make_pair(v, v));
      }
    }
  }
  sol();
  printf("%d\n", ((int)(used).size()));
  for (pair<long long, long long> x : used) {
    long long v = x.second - x.first;
    long long v2 = x.first;
    long long out[5];
    out[4] = 32 - __builtin_popcountll(v);
    for (int i = 3; i >= 0; --i) {
      out[i] = v2 & 255;
      v2 >>= 8;
    }
    printf("%lld.%lld.%lld.%lld/%lld\n", out[0], out[1], out[2], out[3],
           out[4]);
  }
  return 0;
}
