#include <bits/stdc++.h>
using std::vector;
const int N = 6500000;
char s[55];
long long base[15];
int a[55];
struct Node {
  int left, right;
  bool good, bad;
  long long mask;
  Node() {
    mask = 0;
    left = -1, right = -1;
    good = false, bad = false;
  }
};
Node t[N];
int sum[N][2];
int f[N];
int total = 0;
int ok = 1;
int getNumber(int l, int r) {
  int res = 0;
  for (int i = l; i <= r; i++) res = res * 10 + (s[i] - '0');
  return res;
}
void toBinary(long long mask, int n) {
  for (int i = n; i >= 1; i--) {
    long long cur = (mask % 2);
    a[i] = cur;
    mask /= 2;
  }
}
int toString(int n) {
  long long mask = 0;
  int p = 1;
  for (int i = 4; i >= 1; i--) {
    while (s[p] < '0' || s[p] > '9') p++;
    int np = p;
    while (np + 1 <= n && s[np + 1] >= '0' && s[np + 1] <= '9') np++;
    long long cMask = getNumber(p, np);
    mask += cMask * base[i];
    p = np + 1;
  }
  toBinary(mask, 32);
  int len = 32;
  if (p <= n) len = getNumber(p + 1, n);
  return len;
}
void build(int p, int ptr, int size, int tag) {
  if (ptr == size + 1) {
    if (tag)
      t[p].good = 1;
    else
      t[p].bad = 1;
  } else {
    int next = -1;
    if (a[ptr] == 0) {
      if (t[p].left == -1) {
        t[p].left = ++total;
        t[total].mask = t[p].mask * 2ll;
      }
      next = t[p].left;
    } else {
      if (t[p].right == -1) {
        t[p].right = ++total;
        t[total].mask = t[p].mask * 2ll + 1ll;
      }
      next = t[p].right;
    }
    build(next, ptr + 1, size, tag);
  }
}
void dfs(int p) {
  sum[p][1] = t[p].good, sum[p][0] = t[p].bad;
  if (t[p].left != -1) {
    dfs(t[p].left);
    for (int i = 0; i < 2; i++) {
      sum[p][i] += sum[t[p].left][i];
    }
  }
  if (t[p].right != -1) {
    dfs(t[p].right);
    for (int i = 0; i < 2; i++) {
      sum[p][i] += sum[t[p].right][i];
    }
  }
  if (t[p].bad == 1 && sum[p][1] != 0) ok = 0;
  if (t[p].good == 1 && sum[p][0] != 0) ok = 0;
}
void dp(int p) {
  if (sum[p][0] == 0)
    f[p] = 0;
  else {
    if (sum[p][1] == 0) {
      f[p] = 1;
    } else {
      int l = t[p].left, r = t[p].right;
      if (l != -1) {
        dp(l);
        f[p] += f[l];
      }
      if (r != -1) {
        dp(r);
        f[p] += f[r];
      }
    }
  }
}
void printMask(vector<int> u, int len) {
  long long mask = 0;
  for (int i = 0; i < 32; i++) mask = mask * 2 + (long long)u[i];
  int keep[10];
  long long base = 256;
  for (int i = 0; i < 4; i++) {
    long long cur = mask % base;
    keep[i] = cur;
    mask /= base;
  }
  for (int i = 3; i >= 0; i--) {
    printf("%d", keep[i]);
    if (i != 0)
      printf(".");
    else
      printf("/");
  }
  printf("%d\n", len);
}
void newPrint(long long nMask) {
  long long keep[55];
  int size = 0;
  while (nMask != 1ll) {
    keep[++size] = nMask % 2;
    nMask /= 2;
  }
  vector<int> u;
  for (int i = size; i >= 1; i--) u.push_back(keep[i]);
  while (u.size() != 32) u.push_back(0);
  printMask(u, size);
}
void printDfs(int p) {
  if (sum[p][0] == 0)
    return;
  else {
    if (sum[p][1] == 0) {
      newPrint(t[p].mask);
    } else {
      int l = t[p].left, r = t[p].right;
      if (l != -1) {
        printDfs(l);
      }
      if (r != -1) {
        printDfs(r);
      }
    }
  }
}
int main() {
  base[1] = 1;
  for (int i = 2; i <= 4; i++) base[i] = base[i - 1] * 256ll;
  int n;
  scanf("%d", &n);
  int root = ++total;
  t[root].mask = 1ll;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    int size = strlen(s + 1);
    size = toString(size);
    int isGood = 1;
    if (s[1] == '-') isGood = 0;
    build(root, 1, size, isGood);
  }
  dfs(root);
  if (!ok)
    printf("-1\n");
  else {
    dp(root);
    printf("%d\n", f[root]);
    printDfs(root);
  }
  return 0;
}
