#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ll n;
struct ip {
  unsigned int addr;
  unsigned int mask;
};
string encode_ipv4(ip x) {
  string ans;
  for (int b = 3; b >= 0; --b) {
    ans += to_string((x.addr >> (8 * b)) & 0xff);
    if (b > 0)
      ans += '.';
    else
      ans += '/';
  }
  ans += to_string(x.mask);
  return ans;
}
ip parse_ipv4(string ipv4) {
  unsigned int token = 0;
  bool mask = false;
  ip ans = ip{0, 32};
  for (char c : ipv4) {
    if (c == '.' || c == '/') {
      ans.addr <<= 8;
      ans.addr |= token;
      token = 0;
      if (c == '/') {
        mask = true;
      }
    } else {
      token *= 10;
      token += (c - '0');
    }
  }
  if (mask) {
    ans.mask = token;
  } else {
    ans.addr <<= 8;
    ans.addr |= token;
  }
  return ans;
}
struct node {
  node *next[2];
  int type;
  bool has_allowed_children;
  bool has_blocked_children;
};
node *root;
node *new_node() {
  node *x = new node;
  x->next[0] = nullptr;
  x->next[1] = nullptr;
  x->type = 0;
  x->has_allowed_children = false;
  x->has_blocked_children = false;
  return x;
}
void add_ipv4(ip y, int type) {
  node *x = root;
  for (int i = 0; i < y.mask; ++i) {
    int d = (y.addr >> (31 - i)) & 1;
    if (!x->next[d]) {
      x->next[d] = new_node();
    }
    if (type == 1) {
      x->has_allowed_children = true;
    }
    if (type == 2) {
      x->has_blocked_children = true;
    }
    x = x->next[d];
  }
  x->type = type;
  if (type == 1) {
    x->has_allowed_children = true;
  }
  if (type == 2) {
    x->has_blocked_children = true;
  }
}
bool validate(node *x) {
  if (x == nullptr) return true;
  if (x->type == 2 && x->has_allowed_children) return false;
  if (x->type == 1 && x->has_blocked_children) return false;
  return validate(x->next[0]) && validate(x->next[1]);
}
vector<ip> ans;
void print(node *x, ip y) {
  if (x == nullptr) return;
  ip y0 = y;
  y0.mask++;
  ip y1 = y0;
  y1.addr |= (1 << (32 - y1.mask));
  for (int i = 0; i < y.mask; ++i) cout << ' ';
  cout << encode_ipv4(y) << " (" << x->type << ")" << endl;
  print(x->next[0], y0);
  print(x->next[1], y1);
}
int solve(node *x, ip y) {
  if (x == nullptr) return 0;
  if (!x->has_blocked_children && !x->has_allowed_children) return 0;
  if (x->has_allowed_children && !x->has_blocked_children) return 1;
  if (!x->has_allowed_children) return 2;
  ip y0 = y;
  y0.mask++;
  ip y1 = y0;
  y1.addr |= (1 << (32 - y1.mask));
  int v0 = solve(x->next[0], y0);
  int v1 = solve(x->next[1], y1);
  if (v0 == 0 && v1 == 0) return 0;
  if (v0 != 1 && v1 != 1) return 2;
  if (v0 == 1 && v1 == 1) return 1;
  if (v0 == 1 && v1 == 2) {
    ans.push_back(y1);
  }
  if (v1 == 1 && v0 == 2) {
    ans.push_back(y0);
  }
  return 1;
}
int main() {
  root = new_node();
  cin >> n;
  for (ll i = 0; i < (ll)n; ++i) {
    string s;
    cin >> s;
    ip x = parse_ipv4(s.substr(1));
    if (s[0] == '+') {
      add_ipv4(x, 1);
    } else {
      add_ipv4(x, 2);
    }
  }
  if (!validate(root)) {
    cout << -1 << endl;
    return 0;
  }
  int r = solve(root, ip{0, 0});
  if (r == 2) {
    ans.push_back(ip{0, 0});
  }
  cout << ans.size() << endl;
  for (ip x : ans) {
    cout << encode_ipv4(x) << endl;
  }
}
