#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0LL) return b;
  if (b == 0LL) return a;
  return gcd(b, a % b);
}
const int N = 400005;
const int M = 33;
int adj[N * M][2];
int node_cnt = 1;
bool mark[N * M][2];
bool white[N * M];
bool black[N * M];
bool total_black[N * M];
bool total_white[N * M];
bool notPossible;
vector<int> v;
vector<string> ans;
vector<int> recStack;
void convertToBinary(int num) {
  vector<int> temp;
  temp.clear();
  for (int i = 0; i < 8; i++) {
    temp.push_back(num % 2);
    num /= 2;
  }
  reverse(temp.begin(), temp.end());
  for (int i = 0; i < 8; i++) v.push_back(temp[i]);
  return;
}
pair<bool, int> getIP() {
  v.clear();
  pair<bool, int> ans;
  string s;
  getline(cin, s);
  if (s[0] == '-')
    ans.first = false;
  else
    ans.first = true;
  int pt = 0, num;
  for (int i = 0; i < 4; i++) {
    pt++;
    num = 0;
    while (pt < s.size() && s[pt] != '.' && s[pt] != '/') {
      num = num * 10 + s[pt] - '0';
      pt++;
    }
    convertToBinary(num);
  }
  pt++;
  num = 0;
  while (pt < s.size()) {
    num = num * 10 + s[pt] - '0';
    pt++;
  }
  ans.second = num;
  return ans;
}
void insert(int node, bool flag, int pos, int subnet) {
  if (pos == v.size() || pos == subnet) {
    mark[node][flag] = true;
    return;
  }
  if (adj[node][v[pos]] == 0) {
    adj[node][v[pos]] = node_cnt;
    node_cnt++;
  }
  insert(adj[node][v[pos]], flag, pos + 1, subnet);
}
void dfs(int node) {
  black[node] = mark[node][0];
  white[node] = mark[node][1];
  total_black[node] = mark[node][0];
  total_white[node] = mark[node][1];
  for (int i = 0; i < 2; i++)
    if (adj[node][i]) {
      dfs(adj[node][i]);
      white[node] |= white[adj[node][i]];
      black[node] |= black[adj[node][i]];
    }
  if (total_black[node] && white[node]) notPossible = true;
  if (total_white[node] && black[node]) notPossible = true;
  if (!white[node] && black[node]) total_black[node] = true;
  return;
}
void calc_IP() {
  int subnet = recStack.size();
  vector<int> temp;
  temp.clear();
  for (int i = 0; i < recStack.size(); i++) temp.push_back(recStack[i]);
  for (int i = recStack.size(); i < 32; i++) temp.push_back(0);
  int IP[4] = {0, 0, 0, 0};
  for (int i = 0; i < 4; i++)
    for (int j = i * 8; j < i * 8 + 8; j++) IP[i] = IP[i] * 2 + temp[j];
  string s = "";
  s = to_string(IP[0]) + "." + to_string(IP[1]) + "." + to_string(IP[2]) + "." +
      to_string(IP[3]) + "/" + to_string(subnet);
  ans.push_back(s);
  return;
}
void dfs1(int node) {
  if (total_black[node]) {
    calc_IP();
    return;
  }
  for (int i = 0; i < 2; i++)
    if (adj[node][i]) {
      recStack.push_back(i);
      dfs1(adj[node][i]);
      recStack.pop_back();
    }
  return;
}
void solve() {
  int n;
  cin >> n;
  char c;
  pair<bool, int> IP;
  string s;
  getline(cin, s);
  for (int i = 1; i <= n; i++) {
    IP = getIP();
    if (IP.second == 0) IP.second = 32;
    insert(0, IP.first, 0, IP.second);
  }
  notPossible = false;
  dfs(0);
  if (notPossible) {
    cout << "-1\n";
    return;
  }
  recStack.clear();
  dfs1(0);
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << "\n";
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  clock_t clk = clock();
  int t = 1;
  for (int tests = 1; tests <= t; tests++) {
    solve();
  }
  clk = clock() - clk;
  cerr << "Time Elapsed: " << fixed << setprecision(10)
       << ((long double)clk) / CLOCKS_PER_SEC << "\n";
  return 0;
}
