#include <bits/stdc++.h>
using namespace std;
struct ip {
  long long a, b, c, d, m;
};
ip getip(long long num, int mm) {
  return {(num & (255 << 24)) >> 24, (num & (255 << 16)) >> 16,
          (num & (255 << 8)) >> 8, num & 255, mm};
}
vector<ip> numtoip(pair<long long, long long> p) {
  long long s = p.first, e = p.second;
  vector<ip> ans;
  while (s < e) {
    int k = (!s) ? 32 : __builtin_ctzll(s);
    while (s + (1ll << k) - 1 >= e) k--;
    ans.push_back(getip(s, 32 - k));
    s += 1ll << k;
  }
  return ans;
}
pair<long long, long long> iptonum(ip x) {
  long long n =
      x.a * (1 << 24) + x.b * (1 << 16) + x.c * (1 << 8) + x.d * (1 << 0);
  bitset<32> low(n), high(n);
  for (int i = 0, ThxDem = 32 - x.m; i < ThxDem; ++i) low[i] = 0, high[i] = 1;
  return {low.to_ullong(), high.to_ullong() + 1};
}
struct disjoint_intervals {
  set<pair<long long, long long> > s;
  void insert(pair<long long, long long> v) {
    if (v.first >= v.second) return;
    auto at = s.lower_bound(v);
    auto it = at;
    if (at != s.begin() && (--at)->second >= v.first) v.first = at->first, --it;
    for (; it != s.end() && it->first <= v.second; s.erase(it++))
      v.second = max(v.second, it->second);
    s.insert(v);
  }
  bool intersect(pair<long long, long long> v) {
    auto it = s.upper_bound({v.first, -2});
    return (it != s.end() && it->first < v.second) ||
           (it != s.begin() && prev(it)->second > v.first);
  }
};
disjoint_intervals w, b;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
    string s;
    cin >> s;
    s += ".";
    int now = 0, white = s[0] == '+';
    vector<int> v;
    for (int i = 1, ThxDem = ((int)(s).size()); i < ThxDem; ++i) {
      if (s[i] >= '0' && s[i] <= '9')
        now = 10 * now + s[i] - '0';
      else
        v.push_back(now), now = 0;
    }
    if (v.size() < 5) v.push_back(32);
    auto ran = iptonum({v[0], v[1], v[2], v[3], v[4]});
    if (white)
      w.insert(ran);
    else
      b.insert(ran);
  }
  for (auto x : w.s) {
    if (b.intersect(x)) {
      cout << -1 << endl;
      return 0;
    }
  }
  vector<pair<long long, long long> > good = {{-1, 0}}, ans;
  for (auto x : w.s) good.push_back(x);
  good.push_back({1ll << 32, (1ll << 32) + 1ll});
  for (int i = 1, ThxDem = ((int)(good).size()); i < ThxDem; ++i)
    ans.push_back({good[i - 1].second, good[i].first});
  vector<ip> res;
  for (auto xx : ans) {
    vector<ip> x = numtoip(xx);
    for (auto aux : x) {
      auto rr = iptonum(aux);
      if (b.intersect(rr)) res.push_back(aux);
    }
  }
  cout << res.size() << endl;
  for (auto x : res)
    cout << x.a << "." << x.b << "." << x.c << "." << x.d << "/" << x.m << endl;
}
