#include <bits/stdc++.h>
using namespace std;
const int MXM = 2e5 * 40;
vector<pair<long long, int> > ans;
int flag;
struct Trie {
  int nxt[MXM][2], cnt[MXM][2], ed[MXM][2];
  int root, rear;
  int new_node() {
    ++rear;
    memset(cnt[rear], 0, sizeof(cnt[rear]));
    memset(ed[rear], 0, sizeof(ed[rear]));
    memset(nxt[rear], 0, sizeof(nxt[rear]));
    return rear;
  }
  void init() {
    rear = 0;
    root = new_node();
  }
  void insert(int str[], int len, int op) {
    int now = root, tmp;
    cnt[now][op]++;
    for (int i = (0); i < (len); ++i) {
      tmp = str[i];
      if (!nxt[now][tmp]) nxt[now][tmp] = new_node();
      now = nxt[now][tmp];
      cnt[now][op]++;
    }
    ed[now][op]++;
  }
  void dfs(int now, int dep, long long val) {
    if (ed[now][1] && cnt[now][0]) {
      flag = 0;
      return;
    }
    if (ed[now][0] && cnt[now][1]) {
      flag = 0;
      return;
    }
    if (cnt[now][0] == 0) {
      ans.push_back(pair<long long, int>(val, dep));
      return;
    }
    if (nxt[now][0] == 0 && nxt[now][1] == 0) {
      if (cnt[now][0]) flag = 0;
      return;
    }
    if (cnt[nxt[now][0]][1]) dfs(nxt[now][0], dep + 1, val);
    if (cnt[nxt[now][1]][1])
      dfs(nxt[now][1], dep + 1, val | (1ll << (31 - dep)));
  }
  void query() { dfs(root, 0, 0); }
} T;
char str[22];
string s;
int a[33];
int to_int(string st) {
  int ret = 0;
  for (int i = (0); i < (st.length()); ++i) ret = ret * 10 + st[i] - '0';
  return ret;
}
void solve() {
  int l = 1, index = 0;
  for (int i = (1); i < (s.length()); ++i) {
    if (s[i] == '.' || s[i] == '/') {
      string st = s.substr(l, i - l);
      l = i + 1;
      int x = to_int(st);
      for (int j = ((index + 1) * 8) - 1; j >= (index * 8); --j)
        a[j] = x % 2, x >>= 1;
      index++;
    }
  }
}
string to_str(long long x) {
  stringstream stream;
  stream << x;
  return stream.str();
}
void print(pair<long long, int> p) {
  long long x = p.first;
  int y = p.second;
  string st = "";
  for (int i = (0); i < (4); ++i) a[i] = x % 256, x /= 256;
  for (int i = (4) - 1; i >= (0); --i) {
    st += to_str(a[i]);
    if (i > 0) st += '.';
  }
  st += "/" + to_str(y);
  printf("%s\n", st.c_str());
}
int main() {
  int n;
  cin >> n;
  T.init();
  for (int i = (0); i < (n); ++i) {
    scanf("%s", str);
    s = (string)str;
    if ((int)s.find("/") == -1) s += "/32";
    solve();
    int l = s.find("/") + 1, r = s.length() - 1;
    int cnt = to_int(s.substr(l, r - l + 1));
    T.insert(a, cnt, s[0] == '-' ? 1 : 0);
  }
  flag = 1;
  T.query();
  if (!flag) return 0 * printf("-1\n");
  printf("%d\n", ans.size());
  for (pair<long long, int> p : ans) print(p);
  return 0;
}
