#include <bits/stdc++.h>
using namespace std;
struct TrieNode {
  int list, cntBlack, cntWhite;
  bool taken;
  TrieNode* child[2];
  TrieNode() {
    list = cntBlack = cntWhite = 0;
    taken = false;
    child[0] = child[1] = NULL;
  }
} root;
void update(long long bit, int length, bool blacklist) {
  TrieNode* p = &root;
  p->cntBlack += blacklist;
  p->cntWhite += !blacklist;
  for (int i = 1; i <= length; i++) {
    int z = (bit >> (32 - i)) & 1;
    if (p->child[z] == NULL) p->child[z] = new TrieNode();
    p = p->child[z];
    p->cntBlack += blacklist;
    p->cntWhite += !blacklist;
  }
  int save = (blacklist ? -1 : 1);
  if (p->list && p->list != save) {
    cout << -1;
    exit(0);
  }
  p->list = save;
}
struct Rule {
  bool blacklist;
  long long bit;
  int length;
  Rule() {}
  Rule(const string& s) {
    blacklist = (s[0] == '-');
    bit = 0;
    length = 32;
    int siz = s.size(), val = 0, group = 3;
    for (int i = 1; i <= siz - 1; i++) {
      if (s[i] == '.' || s[i] == '/') {
        bit |= val << (group * 8);
        val = 0;
        group--;
        if (s[i] == '/') length = 0;
        continue;
      }
      if (group >= 0)
        val = val * 10 + s[i] - '0';
      else
        length = length * 10 + s[i] - '0';
    }
    if (group == 0) bit |= val;
  }
};
int n;
string s;
Rule r;
vector<pair<long long, int> > ans;
void setup() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    r = Rule(s);
    update(r.bit, r.length, r.blacklist);
  }
}
void dfs(TrieNode* p, long long bit, int length) {
  if (p->list && p->cntBlack && p->cntWhite) {
    cout << -1;
    exit(0);
  }
  if (p->cntBlack == 0) return;
  if (p->cntWhite == 0) {
    ans.push_back(make_pair(bit, length));
    return;
  }
  for (int i = 0; i <= 1; i++)
    if (p->child[i] != NULL)
      dfs(p->child[i], bit | (i << (31 - length)), length + 1);
}
void xuly() {
  dfs(&root, 0, 0);
  cout << ans.size() << '\n';
  for (pair<long long, int> ip : ans) {
    int val = 0;
    for (int i = 31; i >= 0; i--) {
      val = (val << 1) | ((ip.first >> i) & 1);
      if (i % 8 == 0) {
        cout << val;
        val = 0;
        if (i) cout << '.';
      }
    }
    cout << '/' << ip.second << '\n';
  }
}
int main() {
  iostream::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  xuly();
  return 0;
}
