#include <bits/stdc++.h>
using namespace std;
int n, at;
char x[105];
long long y[4];
vector<pair<pair<int, int>, pair<int, int>>> v;
vector<pair<long long, int>> ans;
bool pos;
long long ta;
int tb;
void go(int a, long long b, int c) {
  if (!(v[a].first.second & 1)) {
    ans.emplace_back(b, c);
    return;
  }
  c++;
  if (v[a].second.first && v[v[a].second.first].first.second & 2)
    go(v[a].second.first, b, c);
  if (v[a].second.second && v[v[a].second.second].first.second & 2)
    go(v[a].second.second, b | (1LL << 32 - c), c);
}
int main() {
  v.emplace_back();
  scanf("%d", &n);
  while (n--) {
    scanf("%s", x);
    memset(y, 0, sizeof(y));
    pos = x[0] == '+';
    at = 1;
    while (x[at] != '.') {
      y[0] = y[0] * 10 + x[at] - '0';
      at++;
    }
    at++;
    while (x[at] != '.') {
      y[1] = y[1] * 10 + x[at] - '0';
      at++;
    }
    at++;
    while (x[at] != '.') {
      y[2] = y[2] * 10 + x[at] - '0';
      at++;
    }
    at++;
    while (x[at] != '/' && x[at]) {
      y[3] = y[3] * 10 + x[at] - '0';
      at++;
    }
    if (x[at])
      sscanf(x + at + 1, "%d", &tb);
    else
      tb = 32;
    ta = (y[0] << 24) | (y[1] << 16) | (y[2] << 8) | y[3];
    at = 0;
    for (int i = 31; i > 31 - tb; i--) {
      if (v[at].first.first & (pos ? 2 : 1)) {
        puts("-1");
        return 0;
      }
      v[at].first.second |= pos ? 1 : 2;
      if (ta & (1LL << i)) {
        if (!v[at].second.second) {
          v[at].second.second = v.size();
          v.emplace_back();
        }
        at = v[at].second.second;
      } else {
        if (!v[at].second.first) {
          v[at].second.first = v.size();
          v.emplace_back();
        }
        at = v[at].second.first;
      }
    }
    if (v[at].first.second & (pos ? 2 : 1)) {
      puts("-1");
      return 0;
    }
    v[at].first.first |= pos ? 1 : 2;
    v[at].first.second |= pos ? 1 : 2;
  }
  go(0, 0, 0);
  printf("%d\n", ans.size());
  for (auto& i : ans)
    printf("%lld.%lld.%lld.%lld/%d\n", (i.first & (255LL << 24)) >> 24,
           (i.first & (255LL << 16)) >> 16, (i.first & (255LL << 8)) >> 8,
           i.first & 255, i.second);
  return 0;
}
