#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-6;
const long long EMPTY = -1;
const long long NONE = -2;
const long long MANY = -2;
const long long INF64 = 1e18 + 7;
const long long INF = 1e9 + 7;
const long long MOD = 1e9 + 7;
template <typename T>
void alert(T const &t) {
  cout << t << endl;
  exit(0);
}
struct node_t {
  bitset<32> address;
  char op = '*';
  int height = 32;
  node_t *e[2] = {nullptr, nullptr};
};
vector<node_t *> ans;
istream &operator>>(istream &cin, node_t &node) {
  long long ip[4], address = 0;
  string s;
  char d;
  getline(cin, s);
  stringstream ss(s);
  ss >> node.op >> ip[0] >> d >> ip[1] >> d >> ip[2] >> d >> ip[3];
  for (int i = 0; i < 4; ++i) {
    address <<= 8;
    address += ip[i];
  }
  node.address = address;
  if (ss >> d) ss >> node.height;
  return cin;
}
ostream &operator<<(ostream &cout, node_t &node) {
  long long address = node.address.to_ullong();
  address &= 0xFFFFFFFFLL << (32 - node.height);
  for (int i = 0; i < 4; ++i) {
    if (i) cout << '.';
    cout << ((address & 0xFF000000LL) >> 24);
    address <<= 8;
  }
  cout << '/' << node.height;
  return cout;
}
pair<char, node_t *> solve(node_t *node, char op = '*') {
  if (!node) return {'*', nullptr};
  if (op != '*' && node->op != '*' && op != node->op) alert(-1);
  auto l = solve(node->e[0], max(op, node->op));
  auto r = solve(node->e[1], max(op, node->op));
  if (node->op != '*') return {node->op, node};
  if (min(l, r).first == '*')
    return max({node->op, node}, max(l, r),
               [](pair<char, node_t *> const &a,
                  pair<char, node_t *> const &b) -> bool {
                 if (a.first != b.first) return a.first < b.first;
                 return a.second->height > b.second->height;
               });
  if (l.first == r.first) return {l.first, node};
  if (max(l, r).first == '-') {
    ans.push_back(max(l, r).second);
  }
  return min(l, r);
}
int main() {
  int n;
  cin >> n >> ws;
  ans.reserve(n);
  node_t root;
  root.height = 0;
  for (int i = 0; i < n; ++i) {
    node_t node;
    cin >> node;
    node_t *curr = &root;
    if (curr->op != '*' && curr->op != node.op) {
      alert(-1);
    }
    for (int h = 0; h < node.height; ++h) {
      curr->height = h;
      auto &t = curr->e[node.address[31 - h]];
      if (!t) {
        t = new node_t(node);
        t->op = '*';
      }
      if (t->op != '*' && t->op != node.op) {
        alert(-1);
      }
      curr = t;
    }
    curr->op = node.op;
  }
  auto s = solve(&root, root.op);
  if (s.first == '-') {
    ans.push_back(s.second);
  }
  cout << ans.size() << endl;
  for (auto &node : ans) cout << *node << endl;
  return 0;
}
