#include <bits/stdc++.h>
#pragma GCC optimize("3,Ofast,inline")
using namespace std;
const int MAXN = 200009;
int ch[MAXN * 32][2];
int val[MAXN * 32][2];
int s[MAXN][34];
int f[MAXN], lim[MAXN];
int n, m, tot = 1;
struct IPV4 {
  int a, b, c, d, x;
};
vector<IPV4> ans;
inline void Insert(int x) {
  int now = 1;
  for (int i = 0; i < lim[x]; ++i) {
    if (!ch[now][s[x][i]]) {
      ch[now][s[x][i]] = ++tot;
      ch[tot][0] = ch[tot][1] = 0;
    }
    now = ch[now][s[x][i]];
  }
  val[now][f[x]] = 1;
}
void DFS(int x) {
  int sgn = (val[x][0] ? 0 : (val[x][1] ? 1 : -1));
  if (ch[x][0]) {
    DFS(ch[x][0]);
    val[x][0] += val[ch[x][0]][0];
    val[x][1] += val[ch[x][0]][1];
  }
  if (ch[x][1]) {
    DFS(ch[x][1]);
    val[x][0] += val[ch[x][1]][0];
    val[x][1] += val[ch[x][1]][1];
  }
  if (sgn != -1 && val[x][1 - sgn]) {
    puts("-1");
    exit(0);
  }
}
int tmp[35];
inline void Print(int len) {
  IPV4 now = (IPV4){0, 0, 0, 0, 0};
  now.x = len;
  for (int i = 0; i <= 7 && i <= len; ++i) {
    now.a += tmp[i] << (7 - i);
  }
  for (int i = 8; i <= 15 && i <= len; ++i) {
    now.b += tmp[i] << (15 - i);
  }
  for (int i = 16; i <= 23 && i <= len; ++i) {
    now.c += tmp[i] << (23 - i);
  }
  for (int i = 24; i <= 31 && i <= len; ++i) {
    now.d += tmp[i] << (31 - i);
  }
  ans.push_back(now);
}
void DFS2(int x, int len) {
  if (val[x][0] > 0 && val[x][1] == 0) {
    Print(len);
    return;
  }
  if (val[x][0] == 0) return;
  if (ch[x][0]) {
    tmp[len] = 0;
    DFS2(ch[x][0], len + 1);
  }
  if (ch[x][1]) {
    tmp[len] = 1;
    DFS2(ch[x][1], len + 1);
  }
  tmp[len] = 0;
}
int main() {
  scanf("%d\n", &n);
  for (int i = 1; i <= n; ++i) {
    char sgn = getchar();
    int a, b, c, d;
    scanf("%d.%d.%d.%d", &a, &b, &c, &d);
    for (int j = 7; j >= 0; --j) {
      s[i][7 - j] = ((a >> j) & 1);
    }
    for (int j = 7; j >= 0; --j) {
      s[i][8 + 7 - j] = ((b >> j) & 1);
    }
    for (int j = 7; j >= 0; --j) {
      s[i][16 + 7 - j] = ((c >> j) & 1);
    }
    for (int j = 7; j >= 0; --j) {
      s[i][24 + 7 - j] = ((d >> j) & 1);
    }
    char ch = getchar();
    if (ch == '/') {
      scanf("%d", &lim[i]);
      ch = getchar();
    } else {
      lim[i] = 32;
    }
    f[i] = (sgn == '+' ? 1 : 0);
    Insert(i);
  }
  DFS(1);
  DFS2(1, 0);
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); ++i) {
    printf("%d.%d.%d.%d/%d\n", ans[i].a, ans[i].b, ans[i].c, ans[i].d,
           ans[i].x);
  }
  return 0;
}
