#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int sz = 500;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i].first >> vec[i].second;
  }
  string str = "";
  str.append(n, 'a');
  bool flag = true;
  for (auto x : vec) {
    if (str[x.first - 1] != 'a' && str[x.first - 1] != (x.second + '0')) {
      flag = false;
      break;
    } else
      str[x.first - 1] = (x.second + '0');
  }
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      if (str[i] == '0') {
        flag = false;
        break;
      } else if (str[i] == 'a')
        str[i] = '1';
    } else if (str[i] == 'a')
      str[i] = '0';
  }
  if (!flag)
    puts("-1");
  else
    cout << str << endl;
  return 0;
}
