#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using u = unsigned;
using puu = pair<u, u>;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 2e9 + 5;
vector<puu> black_list;
struct segtree {
  struct node {
    node *left = 0, *right = 0;
    bool white = 0;
    void update() {
      if (left && right) white = white || (left->white && right->white);
    }
    void insert_white(u l, u r, u a = 0, u b = ~0) {
      if (white) return;
      if (a >= l && b <= r) {
        white = 1;
        return;
      }
      u m = a + (b - a) / 2;
      if (l <= m) {
        if (!left) left = new node();
        left->insert_white(l, r, a, m);
      }
      if (r > m) {
        if (!right) right = new node();
        right->insert_white(l, r, m + 1, b);
      }
      update();
    }
    int insert_black(u l, u r, u a = 0, u b = ~0) {
      if (white) return -1;
      if (a >= l && b <= r) {
        return -1;
      }
      u m = a + (b - a) / 2;
      if (l <= m) {
        if (!left) {
          black_list.push_back({a, m});
        } else {
          if (left->insert_black(l, r, a, m) == -1) return -1;
        }
      }
      if (r > m) {
        if (!right) {
          black_list.push_back({m + 1, b});
        } else {
          if (right->insert_black(l, r, m + 1, b) == -1) return -1;
        }
      }
      return 0;
    }
  };
  node root;
  void insert_white(u l, u r) { root.insert_white(l, r); }
  int insert_black(u l, u r) { return root.insert_black(l, r); }
};
bool contains(const puu &a, const puu &b) {
  return b.first >= a.first && b.second <= a.second;
}
vector<puu> reduce(const vector<puu> &v) {
  vector<puu> ans{v[0]};
  for (int i = 1; i < v.size(); i++)
    if (!contains(ans.back(), v[i])) ans.push_back(v[i]);
  return move(ans);
}
string convert(u x) {
  u p1 = x >> 24;
  u p2 = (x << 8) >> 24;
  u p3 = (x << 16) >> 24;
  u p4 = (x << 24) >> 24;
  return to_string(p1) + "." + to_string(p2) + "." + to_string(p3) + "." +
         to_string(p4);
}
u bitmask_size(u size) { return 32 - log2(size); }
int main() {
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
  int n;
  cin >> n;
  vector<puu> bad, good;
  while (n--) {
    char t;
    cin >> t;
    u a, b, c, d, x;
    char bidone;
    cin >> a >> bidone >> b >> bidone >> c >> bidone >> d;
    if (cin.peek() == '/')
      cin >> bidone >> x;
    else
      x = 32;
    u val = (a << 24) + (b << 16) + (c << 8) + d;
    u mask = 0xffffffff << (32 - x);
    puu r{val & mask, val | (~mask)};
    if (t == '-')
      bad.push_back(r);
    else
      good.push_back(r);
  }
  if (good.empty()) {
    return cout << "1\n0.0.0.0/0\n", 0;
  }
  segtree st;
  for (puu &p : good) st.insert_white(p.first, p.second);
  for (puu &p : bad)
    if (st.insert_black(p.first, p.second) == -1) {
      return cout << -1 << '\n', 0;
    }
  auto x = black_list;
  sort(x.begin(), x.end(), [](puu &a, puu &b) {
    return a.first == b.first ? a.second > b.second : a.first < b.first;
  });
  x = reduce(x);
  cout << x.size() << '\n';
  for (puu &p : x) {
    cout << convert(p.first) << "/" << bitmask_size(p.second - p.first + 1)
         << endl;
  }
  return cout << '\n', 0;
}
