#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
struct node {
  int C[2];
  ll good;
  ll bad;
  char mrk;
  node() : C{0, 0}, good{0}, bad{0}, mrk{0} {}
  int& operator[](int i) { return C[i]; }
};
using trie_t = vector<node>;
trie_t T;
string curr;
struct Guard {
  Guard(char c) { curr.push_back(c); }
  ~Guard() { curr.pop_back(); }
};
int insert(const string& s, int i = 0, int r = 0) {
  if (i == s.size()) return r;
  if (!T[r][s[i] - '0']) {
    T[r][s[i] - '0'] = T.size();
    T.emplace_back();
  }
  return insert(s, i + 1, T[r][s[i] - '0']);
}
string read() {
  string ans;
  int a, b, c, d, x;
  scanf(" %d.%d.%d.%d", &a, &b, &c, &d);
  if (getchar() != '/')
    x = 32;
  else
    scanf("%d", &x);
  ll num = a;
  num = (num << 8) + b;
  num = (num << 8) + c;
  num = (num << 8) + d;
  num >>= (32 - x);
  for (; x > 0; x--, num >>= 1) ans.push_back('0' + char(num & 1ll));
  reverse(begin(ans), end(ans));
  return ans;
}
void sum(int r) {
  T[r].good = (T[r].mrk == '+');
  T[r].bad = (T[r].mrk == '-');
  if (T[r][0]) {
    sum(T[r][0]);
    T[r].good += T[T[r][0]].good;
    T[r].bad += T[T[r][0]].bad;
  }
  if (T[r][1]) {
    sum(T[r][1]);
    T[r].good += T[T[r][1]].good;
    T[r].bad += T[T[r][1]].bad;
  }
}
bool imp = false;
vector<string> ans;
void solve(int r) {
  if (T[r].good * T[r].bad == 0) {
    if (T[r].bad > 0) {
      ans.push_back(curr);
    }
    return;
  }
  if ((T[r].mrk == '+' && T[r].bad > 0) || (T[r].mrk == '-' && T[r].good > 0)) {
    imp = true;
    return;
  }
  if (T[r][0]) {
    Guard g('0');
    solve(T[r][0]);
  }
  if (T[r][1]) {
    Guard g('1');
    solve(T[r][1]);
  }
}
void display(string s) {
  int a, b, c, d, x;
  x = s.size();
  ll num = 0;
  for (int i = 0; i < s.size(); i++) num = 2ll * num + (s[i] - '0');
  num <<= (32 - x);
  d = num % (1 << 8);
  num >>= 8;
  c = num % (1 << 8);
  num >>= 8;
  b = num % (1 << 8);
  num >>= 8;
  a = num % (1 << 8);
  num >>= 8;
  printf("%d.%d.%d.%d/%d\n", a, b, c, d, x);
}
int main() {
  int n;
  int root = 0;
  T.emplace_back();
  scanf(" %d", &n);
  for (int i = 0; i < n; i++) {
    char c;
    while (isspace(c = getchar()))
      ;
    int leaf = insert(read());
    if (T[leaf].mrk) {
      if (T[leaf].mrk != c) imp = true;
    } else
      T[leaf].mrk = c;
  }
  sum(root);
  solve(root);
  if (imp) {
    puts("-1");
    return 0;
  }
  printf("%d\n", ans.size());
  for (auto s : ans) display(s);
}
