#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
template <class T>
inline bool MX(T &l, const T &r) {
  return l < r ? l = r, 1 : 0;
}
template <class T>
inline bool MN(T &l, const T &r) {
  return l > r ? l = r, 1 : 0;
}
struct Node {
  long long l;
  long long r;
  array<Node *, 2> ch;
  int bits;
  Node(long long l, long long r, int bits) : l(l), r(r), ch(), bits(bits) {}
};
int N;
Node *root;
char buf[114514];
Node *Reg(long long wishl, long long wishr, Node *node, long long watchl,
          long long watchr, bool black) {
  if (wishr <= watchl || watchr <= wishl) return node;
  if (wishl <= watchl && watchr <= wishr) {
    assert(wishl == watchl && watchr == wishr);
    if (!node) node = new Node(wishl, wishr, 1 << black);
    node->bits |= (1 << black);
    if (node->bits == 3) {
      puts("-1");
      exit(0);
    }
    assert(node->bits == (1 << black));
    return node;
  }
  if (!node) node = new Node(watchl, watchr, 1 << black);
  node->bits |= 1 << black;
  long long mid = (watchl + watchr) / 2;
  node->ch[0] = Reg(wishl, wishr, node->ch[0], watchl, mid, black);
  node->ch[1] = Reg(wishl, wishr, node->ch[1], mid, watchr, black);
  return node;
}
int Cnt(long long v) {
  int ret = 0;
  while (1) {
    v /= 2;
    if (v == 0) return ret;
    ret++;
  }
}
vector<string> ans;
void Dfs(Node *node) {
  if (!node) return;
  if (!(node->bits >> 1 & 1)) return;
  if (!(node->bits & 1)) {
    long long l = node->l;
    long long r = node->r;
    assert(node->bits >> 1);
    long long a = (l >> 24) & 255LL;
    long long b = (l >> 16) & 255LL;
    long long c = (l >> 8) & 255LL;
    long long d = (l)&255LL;
    int m = Cnt(r - l);
    assert((1LL << m) == r - l);
    assert((((1LL << m) - 1) & l) == 0);
    if (m > 0) {
      sprintf(buf, "%lld.%lld.%lld.%lld/%d", a, b, c, d, 32 - m);
    } else {
      sprintf(buf, "%lld.%lld.%lld.%lld", a, b, c, d, 32 - m);
    }
    ans.emplace_back(buf);
    return;
  }
  Dfs(node->ch[0]);
  Dfs(node->ch[1]);
}
using Tup = tuple<int, long long, bool>;
vector<Tup> ts;
int main() {
  scanf("%d", &N);
  root = new Node(0, 1LL << 32, 0);
  fgets(buf, sizeof(buf), stdin);
  for (int(i) = (0); (i) < (N); ++(i)) {
    buf[0] = '\0';
    fgets(buf, sizeof(buf), stdin);
    bool black = buf[0] == '-';
    long long a, b, c, d;
    int m = 0;
    if (strchr(buf, '/')) {
      int ret = sscanf(buf + 1, "%lld.%lld.%lld.%lld/%d", &a, &b, &c, &d, &m);
      assert(ret == 5);
      m = 32 - m;
    } else {
      int ret = sscanf(buf + 1, "%lld.%lld.%lld.%lld", &a, &b, &c, &d);
      assert(ret == 4);
    }
    long long l = (a << 24) + (b << 16) + (c << 8) + d;
    assert((((1LL << m) - 1) & l) == 0);
    ts.emplace_back(Tup(m, l, black));
  }
  sort((ts).begin(), (ts).end());
  for (auto &t : ts) {
    int m;
    long long l;
    bool black;
    tie(m, l, black) = t;
    long long r = l + (1LL << m);
    Reg(l, r, root, 0, 1LL << 32, black);
  }
  Dfs(root);
  printf("%d\n", (int)ans.size());
  for (auto &str : ans) {
    printf("%s\n", str.c_str());
  }
  return 0;
}
