#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
string s;
int n;
unsigned int a, b, c, d, x;
struct State {
  unsigned int val, rg;
  State() {}
  State(unsigned int a, unsigned int b) : val(a), rg(b) {}
};
vector<State> vec[2];
struct Node {
  int col, tag;
  Node *lc, *rc;
  Node() {}
  Node(int x) : col(x), tag(0), lc(0), rc(0) {}
  inline void update() {
    if (lc && lc->col == 2)
      col = 2;
    else if (rc && rc->col == 2)
      col = 2;
    else if (lc && rc && lc->col != rc->col)
      col = 2;
    if (lc && rc && lc->tag && rc->tag) tag = 1;
  }
} node[MAXN * 33], *root = 0;
int pnode = 0;
inline Node *newnode(int x) {
  node[pnode] = Node(x);
  return &node[pnode++];
}
void insert(Node *&p, unsigned int val, int rg, int col, int h = 32) {
  if (!p) p = newnode(col);
  if (h > rg) {
    if (p->tag && p->col != 2 && p->col != col) {
      cout << -1 << endl;
      exit(0);
    }
  } else {
    if (p->col != col) {
      cout << -1 << endl;
      exit(0);
    }
    p->tag = 1;
    return;
  }
  if (val & (1ll << (h - 1)))
    insert(p->rc, val, rg, col, h - 1);
  else
    insert(p->lc, val, rg, col, h - 1);
  p->update();
}
vector<State> res;
void dfs(Node *p, unsigned int val = 0, int h = 32) {
  if (!p) return;
  if (p->col == 1) return;
  if (p->col == 0) {
    res.emplace_back(State(val, h));
    return;
  }
  dfs(p->lc, val, h - 1);
  dfs(p->rc, val + (1ll << (h - 1)), h - 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    bool col = (s[0] == '-' ? 0 : 1);
    if (s.find('/') != string::npos) {
      for (auto &c : s)
        if (c == '-' || c == '+' || c == '.' || c == '/') c = ' ';
      stringstream ss(s);
      ss >> a, ss >> b, ss >> c, ss >> d, ss >> x;
    } else {
      for (auto &c : s)
        if (c == '-' || c == '+' || c == '.' || c == '/') c = ' ';
      stringstream ss(s);
      ss >> a, ss >> b, ss >> c, ss >> d, x = 32;
    }
    vec[col].emplace_back(State((a << 24) + (b << 16) + (c << 8) + d, 32 - x));
  }
  for (int i = 0; i < 2; i++)
    for (auto w : vec[i]) insert(root, w.val, w.rg, i);
  dfs(root);
  cout << res.size() << endl;
  unsigned int X = (1 << 8) - 1;
  for (auto v : res) {
    unsigned int x = v.val;
    cout << ((x >> 24) & X) << '.' << ((x >> 16) & X) << '.' << ((x >> 8) & X)
         << '.' << (x & X);
    if (v.rg != 0)
      cout << '/' << 32 - v.rg << endl;
    else
      cout << endl;
  }
  return 0;
}
