#include <bits/stdc++.h>
using namespace std;
using uuint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &item) {
  out << '(' << item.first << ", " << item.second << ')';
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  for (const auto &item : v) out << item << ' ';
  return out;
}
vector<pair<uuint, int>> vblack, vwhite, ans;
set<pair<uuint, int>> white, black, minBlack;
uuint removeBit(uuint x, int b) {
  if (x & (uuint(1) << b)) return x ^ (uuint(1) << b);
  return x;
}
void add(uuint val, int nrb, set<pair<uuint, int>> &white) {
  while (nrb > 0) {
    white.insert({val, nrb});
    val = removeBit(val, 32 - nrb);
    --nrb;
  }
  white.insert({0, 0});
}
int main() {
  int n, nrb;
  uuint a, b, c, d;
  char sgn, ch;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf(" %c%I64d.%I64d.%I64d.%I64d%c", &sgn, &a, &b, &c, &d, &ch);
    if (ch == '/')
      scanf("%d", &nrb);
    else
      nrb = 32;
    uuint val = (a << 24) | (b << 16) | (c << 8) | d;
    if (sgn == '-')
      vblack.push_back({val, nrb}), add(val, nrb, black);
    else
      vwhite.push_back({val, nrb}), add(val, nrb, white);
  }
  for (auto [val, nrb] : vwhite) {
    if (black.count({val, nrb})) return cout << -1 << '\n', 0;
  }
  for (auto [val, nrb] : vblack) {
    if (white.count({val, nrb})) return cout << -1 << '\n', 0;
    while (nrb > 0) {
      uuint newVal = removeBit(val, 32 - nrb);
      if (white.count({newVal, nrb - 1})) break;
      val = newVal;
      --nrb;
    }
    minBlack.insert({val, nrb});
  }
  cout << minBlack.size() << '\n';
  for (auto [val, nrb] : minBlack) {
    cout << (val >> 24) << '.' << ((val >> 16) & 255) << '.'
         << ((val >> 8) & 255) << '.' << (val & 255) << '/' << nrb << '\n';
  }
  return 0;
}
