#include <bits/stdc++.h>
using namespace std;
set<unsigned int> black[33], white[33];
unsigned int masks[33];
string parseipB(unsigned int x, int mask) {
  string s = "";
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 8; ++j) {
      s += to_string(1 & x >> 8 * i + j);
    }
    if (i != 3) s += ".";
  }
  s += '/' + to_string(mask);
  return s;
}
string parseip(unsigned int x, int mask) {
  string s = "";
  for (int i = 0; i < 4; ++i) {
    int val = 0;
    for (int j = 7; j >= 0; --j) {
      val += (1 & x >> 8 * i + j) << 7 - j;
    }
    s += to_string(val);
    if (i != 3) s += ".";
  }
  s += '/' + to_string(mask);
  return s;
}
int main() {
  masks[0] = 0;
  for (int i = 1; i < 33; ++i) {
    masks[i] = masks[i - 1] | (1 << (i - 1));
  }
  int n;
  scanf("%d\n", &n);
  bool hasblacks = false, haswhites = false;
  for (int i = 0; i < n; ++i) {
    char sign, sub;
    int arr[4];
    int mask;
    scanf("%c%d.%d.%d.%d", &sign, &arr[0], &arr[1], &arr[2], &arr[3]);
    scanf("%c", &sub);
    if (sub == '/') {
      scanf("%d\n", &mask);
    } else {
      mask = 32;
    }
    unsigned int val = 0;
    for (int j = 0; j < 4; ++j) {
      unsigned int oct = 0;
      for (int k = 7; k >= 0; --k) {
        oct += (1 & arr[j] >> 7 - k) << k;
      }
      val += (oct << (8 * j));
    }
    if (sign == '-') {
      hasblacks = true;
      black[mask].insert(val);
    } else {
      haswhites = true;
      white[mask].insert(val);
    }
  }
  if (hasblacks && !haswhites) {
    cout << "1\n0.0.0.0/0\n";
    return 0;
  }
  if (!hasblacks && haswhites) {
    cout << "0\n";
    return 0;
  }
  bool ok = true;
  for (int i = 32; i >= 0; --i) {
    for (unsigned int x : white[i]) {
      for (int j = 32; j >= 0; --j) {
        if (black[j].count(masks[j] & x) != 0) {
          ok = false;
          break;
        }
      }
    }
    for (unsigned int x : black[i]) {
      for (int j = 32; j >= 0; --j) {
        if (white[j].count(masks[j] & x) != 0) {
          ok = false;
          break;
        }
      }
    }
  }
  if (!ok) {
    cout << "-1\n";
    return 0;
  }
  vector<pair<unsigned int, unsigned int> > ans;
  for (int i = 32; i > 0; --i) {
    for (unsigned int x : white[i]) {
      white[i - 1].insert(masks[i - 1] & x);
    }
    for (unsigned int x : black[i]) {
      bool shift = white[i].count(x ^ (1 << i - 1)) == 0;
      if (shift) {
        black[i - 1].insert(masks[i - 1] & x);
      } else {
        ans.push_back(pair<unsigned int, unsigned int>(x, i));
      }
    }
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); ++i) {
    unsigned int val = ans[i].first;
    int mask = ans[i].second;
    cout << parseip(val, mask) << '\n';
  }
  return 0;
}
