#include <bits/stdc++.h>
using namespace std;
struct node {
  bool black, white, has_black_children, has_white_children;
  node *left, *right;
};
node *new_node() {
  node *tree = new node;
  tree->black = tree->white = tree->has_black_children =
      tree->has_white_children = false;
  tree->left = tree->right = nullptr;
  return tree;
}
struct ipv4 {
  unsigned long address;
  short x;
};
node *root;
void create_subnet(bool list, ipv4 subnet) {
  node *tree = root;
  for (short i = 0; i < subnet.x; ++i) {
    if (tree->left == nullptr) tree->left = new_node();
    if (tree->right == nullptr) tree->right = new_node();
    if (!list) tree->has_black_children = true;
    if (list) tree->has_white_children = true;
    tree = (!((subnet.address >> (31 - i)) & 1)) ? tree->left : tree->right;
  }
  if (tree == nullptr) tree = new_node();
  if (!list) tree->has_black_children = true;
  if (list) tree->has_white_children = true;
  tree->black = !list;
  tree->white = list;
}
inline bool verify(node *tree) {
  if (tree == nullptr) return true;
  if (tree->black && tree->has_white_children) return false;
  if (tree->white && tree->has_black_children) return false;
  return verify(tree->left) && verify(tree->right);
}
vector<ipv4> ans;
inline void solve(node *tree, ipv4 subnet) {
  if (tree->has_black_children && !tree->has_white_children)
    ans.push_back(subnet);
  else {
    ++subnet.x;
    if (tree->left) solve(tree->left, subnet);
    subnet.address |= 1 << (32 - subnet.x);
    if (tree->right) solve(tree->right, subnet);
  }
}
int main() {
  long n;
  cin >> n;
  root = new_node();
  for (long i = 0; i < n; ++i) {
    char list;
    cin >> list;
    char c;
    ipv4 subnet;
    subnet.address = 0;
    for (short i = 24; i >= 0; i -= 8) {
      short a;
      cin >> a;
      subnet.address += a << i;
      c = cin.get();
    }
    if (c == '/')
      cin >> subnet.x;
    else
      subnet.x = 32;
    create_subnet(list == '+', subnet);
  }
  if (!verify(root)) {
    cout << -1;
    return 0;
  }
  ipv4 subnet;
  subnet.address = subnet.x = 0;
  solve(root, subnet);
  cout << ans.size() << endl;
  long i;
  for (i = 0; i < ans.size(); ++i)
    cout << ((ans[i].address >> 24) & 255) << '.'
         << ((ans[i].address >> 16) & 255) << '.'
         << ((ans[i].address >> 8) & 255) << '.' << (ans[i].address & 255)
         << '/' << ans[i].x << endl;
  return 0;
}
