#include <bits/stdc++.h>
using namespace std;
template <class T>
void na(vector<T>& a, int n) {
  a = vector<T>(n);
  for (T& i : a) cin >> i;
}
template <class T>
void printVector(vector<T>& a) {
  for (T& i : a) cout << i << ' ';
  cout << '\n';
}
template <class T>
vector<T> shrink(vector<T>& x) {
  vector<T> vals = x;
  sort((vals).begin(), (vals).end());
  (vals).resize(unique((vals).begin(), (vals).end()) - (vals).begin());
  for (T& i : x)
    i = upper_bound((vals).begin(), (vals).end(), i) - vals.begin();
  return vals;
}
const long long int SUPER = (1ll << 32) - 1, B = 1ll << 8;
inline long long int _log2(long long int x) { return 63 - __builtin_clzll(x); }
pair<long long int, long long int> toRange(string str);
string toRange(pair<long long int, long long int> a);
struct Range {
  long long int x, y;
  int col;
  Range() {}
  Range(long long int x, long long int y, int col) : x(x), y(y), col(col) {}
  bool operator<(const Range& r) const {
    if (x != r.x) return x < r.x;
    return y < r.y;
  }
  inline bool intersectsQ(Range r) {
    return (r.x <= x && x <= r.y) || (x <= r.x && r.x <= y);
  }
  Range mergeWith(Range r) { return Range(min(x, r.x), max(y, r.y), col); }
  void print() {
    cout << toRange(make_pair(x, x)) << " - " << toRange(make_pair(y, y));
    cout << "    [" << x << " - " << y << "]\n";
  }
};
set<Range> compress(vector<Range>& A) {
  set<Range> res;
  for (auto& a : A) {
    if (res.empty())
      res.insert(a);
    else {
      auto it = res.upper_bound(a);
      if (it != res.begin()) it--;
      Range nrang = a;
      vector<Range> del;
      if (a.intersectsQ(*it)) del.push_back(*it), nrang = nrang.mergeWith(*it);
      it++;
      for (; it != res.end(); it++)
        if (a.intersectsQ(*it)) {
          nrang = nrang.mergeWith(*it);
          del.push_back(*it);
        } else
          break;
      for (auto d : del) res.erase(d);
      res.insert(nrang);
    }
  }
  return res;
}
bool ok(set<Range>& A, set<Range>& B) {
  if (((int)(A).size()) == 0) return true;
  for (Range b : B) {
    auto it = A.upper_bound(b);
    if (it != A.begin()) it--;
    if (b.intersectsQ(*it)) return false;
    it++;
    if (it != A.end() && b.intersectsQ(*it)) return false;
  }
  return true;
}
bool check(long long int ip, long long int a, long long int b) {
  return a < ip && ip < b;
}
long long int get(long long int& ip, long long int a, long long int b) {
  long long int lastOn = ip;
  for (int i = 0; i <= 32; ++i) {
    if (!check(ip, a, b) || !check(ip + (1ll << i) - 1, a, b))
      return ip = lastOn, (long long int)i - 1;
    lastOn = ip;
    if ((ip >> i) & 1ll) {
      ip ^= 1ll << i;
    }
  }
  return 32;
}
void solveFor(vector<Range>& ans, vector<Range>& blackRanges, long long int A,
              long long int B) {
  long long int curIp = A + 1;
  for (int i = 0; i < ((int)(blackRanges).size()); ++i) {
    if (blackRanges[i].y < curIp) continue;
    curIp = max(curIp, blackRanges[i].x);
    do {
      long long int x = get(curIp, A, B);
      long long int oIp = curIp + (1ll << x) - 1;
      ans.emplace_back(curIp, oIp, 1);
      curIp = oIp + 1;
    } while (curIp < blackRanges[i].y);
  }
}
void solve() {
  int n;
  cin >> n;
  vector<Range> _wh, _bl;
  for (int i = 1; i <= n; ++i) {
    string str;
    cin >> str;
    pair<long long int, long long int> r = toRange(str);
    if (str[0] == '+')
      _wh.emplace_back(r.first, r.second, 0);
    else
      _bl.emplace_back(r.first, r.second, 1);
  }
  auto wh = compress(_wh);
  auto bl = compress(_bl);
  if (!ok(wh, bl)) {
    cout << "-1\n";
    return;
  }
  vector<Range> tg;
  for (auto& i : wh) tg.push_back(i);
  for (auto& i : bl) tg.push_back(i);
  sort((tg).begin(), (tg).end());
  vector<Range> ans;
  for (int i = 0, j; i < ((int)(tg).size()); i = j) {
    j = i;
    if (tg[i].col == 1 && (i == 0 || tg[i - 1].col == 0)) {
      vector<Range> blackRanges;
      while (j < ((int)(tg).size()) && tg[j].col == 1) {
        blackRanges.push_back(tg[j]);
        ++j;
      }
      solveFor(ans, blackRanges, i > 0 ? tg[i - 1].y : -1,
               j < ((int)(tg).size()) ? tg[j].x : SUPER + 1);
    } else
      j = i + 1;
  }
  cout << ((int)(ans).size()) << '\n';
  for (Range& a : ans) cout << toRange(make_pair(a.x, a.y)) << '\n';
}
int main() {
  solve();
  return 0;
}
string toRange(pair<long long int, long long int> a) {
  long long int x = a.second - a.first;
  assert((x & (x + 1)) == 0);
  x = 32ll - _log2(x + 1);
  string X = to_string(x);
  string IP = "";
  x = a.first;
  for (int i = 1; i <= 4; ++i) {
    long long int tmp = x % B;
    x /= B;
    IP = to_string(tmp) + "." + IP;
  }
  IP.pop_back();
  return string(IP + "/" + X);
}
pair<long long int, long long int> toRange(string str) {
  auto it = str.begin();
  while (!isdigit(*it)) it++;
  long long int a = 0;
  string tmp = "";
  while (it != str.end() && *it != '/') {
    if (*it == '.') {
      long long int x = stoll(tmp);
      a = a * B + x;
      tmp = "";
    } else
      tmp += *it;
    it++;
  }
  long long int x = stoll(tmp);
  a = a * B + x;
  pair<long long int, long long int> res = make_pair(a, a);
  if (it != str.end()) {
    tmp = "";
    it++;
    while (it != str.end()) tmp += *it++;
    x = 32ll - stoll(tmp);
    res.second += (1ll << x) - 1;
  }
  return res;
}
