#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 2;
const int INF = INT_MAX / 2;
const int MOD = 998244353;
pair<unsigned int, unsigned int> process(string s) {
  s = s.substr(1);
  int fixed;
  unsigned int number = 0;
  if (s.find('/') == -1) {
    fixed = 32;
    replace(s.begin(), s.end(), '.', ' ');
    stringstream ss(s);
    for (int i = 0; i < 4; i++) {
      int x;
      ss >> x;
      number <<= 8;
      number += x;
    }
  } else {
    replace(s.begin(), s.end(), '.', ' ');
    replace(s.begin(), s.end(), '/', ' ');
    stringstream ss(s);
    for (int i = 0; i < 4; i++) {
      int x;
      ss >> x;
      number <<= 8;
      number += x;
    }
    ss >> fixed;
  }
  return {number, fixed};
}
int trie[2][MAXN * 32][2], nodes[2];
int finish[2][MAXN * 32];
void add(unsigned int x, int neg, int fixed) {
  int cur = 0;
  for (int i = 31; i >= 32 - fixed; i--) {
    int id = (x >> i & 1);
    if (!trie[neg][cur][id]) trie[neg][cur][id] = ++nodes[neg];
    cur = trie[neg][cur][id];
  }
  finish[neg][cur] = 1;
}
bool check(unsigned int x, int fixed) {
  int cur = 0;
  for (int i = 31; i >= 32 - fixed; i--) {
    int id = (x >> i & 1);
    if (!trie[0][cur][id]) return true;
    cur = trie[0][cur][id];
    if (finish[0][cur]) {
      return false;
    }
  }
  return false;
}
vector<pair<unsigned int, unsigned int> > ans;
void dfs(int u, int v, unsigned int number, int fixed) {
  for (int neigh = 0; neigh <= 1; neigh++) {
    if (trie[1][u][neigh]) {
      if (trie[0][v][neigh]) {
        dfs(trie[1][u][neigh], trie[0][v][neigh],
            number | (neigh << (31 - fixed)), fixed + 1);
      } else {
        ans.push_back({number | (neigh << (31 - fixed)), fixed + 1});
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  while (cin >> n) {
    nodes[0] = nodes[1] = 0;
    memset(finish, 0, sizeof finish);
    ans.clear();
    vector<pair<unsigned int, unsigned int> > negative;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      if (s[0] == '+') {
        pair<unsigned int, unsigned int> cur = process(s);
        add(cur.first, 0, cur.second);
      } else {
        pair<unsigned int, unsigned int> cur = process(s);
        negative.push_back(cur);
      }
    }
    if (negative.size() == n) {
      cout << "1\n0.0.0.0/0" << '\n';
      continue;
    }
    bool can = 1;
    for (auto &e : negative) {
      add(e.first, 1, e.second);
      can &= check(e.first, e.second);
    }
    if (!can) {
      cout << -1 << '\n';
    } else {
      dfs(0, 0, 0, 0);
      cout << ans.size() << '\n';
      vector<unsigned int> numbers(4);
      for (auto &e : ans) {
        for (int i = 0; i < 4; i++) {
          numbers[3 - i] = e.first & ((1 << 8) - 1);
          e.first >>= 8;
        }
        for (int i = 0; i < 4; i++) {
          cout << numbers[i];
          if (i < 3)
            cout << ".";
          else
            cout << "/";
        }
        cout << e.second << '\n';
      }
    }
  }
  return 0;
}
