#include <bits/stdc++.h>
using namespace std;
set<long long> blackSet[33];
set<long long> whiteSet[33];
vector<int> parse(string s) {
  vector<int> result;
  int currentValue = 0;
  for (auto x : s) {
    if ('0' <= x and x <= '9') {
      currentValue = currentValue * 10 + x - '0';
    } else {
      result.push_back(currentValue);
      currentValue = 0;
    }
  }
  result.push_back(currentValue);
  if (result.size() == 4) {
    result.push_back(32);
  }
  return result;
}
void print(long long value, int bits) {
  long long power = 255;
  for (int i = 1; i <= 3; ++i) power *= 256;
  for (int i = 1; i <= 4; ++i) {
    cout << ((value & power) >> (8 * (4 - i)));
    if (i < 4) cout << '.';
    power /= 256;
  }
  cout << '/' << bits << '\n';
}
bool checkOriginals(vector<pair<pair<long long, long long>, int>> originals) {
  vector<pair<long long, int>> sorted;
  for (auto x : originals) {
    if (x.second == 1) {
      sorted.emplace_back(x.first.first, 1);
      sorted.emplace_back(x.first.second, 3);
    } else {
      sorted.emplace_back(x.first.first, 2);
      sorted.emplace_back(x.first.second, 4);
    }
  }
  int sum1 = 0, sum2 = 0;
  sort(sorted.begin(), sorted.end());
  for (auto x : sorted) {
    if (x.second == 1) {
      sum1 += 1;
    } else if (x.second == 3) {
      sum1 -= 1;
    } else if (x.second == 2) {
      sum2 += 1;
    } else {
      sum2 -= 1;
    }
    if (sum1 && sum2) {
      return false;
    }
  }
  return true;
}
long long getRelevant(long long value, int x) {
  return value & (((1LL << x) - 1) << (32 - x));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  vector<pair<long long, int>> black, white;
  vector<pair<pair<long long, long long>, int>> originals;
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    char sgn;
    cin >> sgn;
    string s;
    cin >> s;
    vector<int> r = parse(s);
    long long value = 0;
    for (int i = 0; i <= 3; ++i) {
      value = value * 256 + r[i];
    }
    long long right =
        (value & getRelevant(value, r.back())) + ((1LL << (32 - r.back())) - 1);
    if (sgn == '-') {
      black.emplace_back(value, r.back());
      originals.push_back({{value, right}, 0});
    } else {
      white.emplace_back(value, r.back());
      originals.push_back({{value, right}, 1});
    }
  }
  if (!checkOriginals(originals)) {
    cout << -1;
    return 0;
  }
  if (black.size() == 0) {
    cout << 0;
    return 0;
  }
  for (auto y : white) {
    long long value = y.first;
    int x = y.second;
    while (x >= 0) {
      value = getRelevant(value, x);
      whiteSet[x].insert(value);
      x -= 1;
    }
  }
  for (auto y : black) {
    long long value = y.first;
    int x = y.second;
    while (true) {
      int newX = x - 1;
      if (newX < 0) break;
      long long newValue = getRelevant(value, newX);
      if (whiteSet[newX].find(newValue) != whiteSet[newX].end()) break;
      x = newX;
      value = newValue;
    }
    blackSet[x].insert(value);
  }
  int total = 0;
  for (int i = 0; i <= 32; ++i) {
    total += blackSet[i].size();
  }
  cout << total << '\n';
  for (int i = 0; i <= 32; ++i) {
    for (auto x : blackSet[i]) {
      print(x, i);
    }
  }
}
