#include <bits/stdc++.h>
using namespace std;
int a[10];
int main() {
  int m, n;
  cin >> m >> n;
  if (n == 1 && !m) {
    cout << "0" << endl;
    return 0;
  }
  memset(a, -1, sizeof(a));
  bool f = false;
  for (int i = 1; i <= m; i++) {
    int s, c;
    cin >> s >> c;
    if (n != 1 && s == 1 && c == 0)
      f = 1;
    else if (a[s] == -1)
      a[s] = c;
    else
      f = a[s] == c ? 0 : 1;
  }
  if (f) cout << "-1" << endl;
  string ans = " ";
  for (int i = 1; i <= n; i++) {
    if (a[i] == -1)
      a[i] = 0;
    else if (a[i] == -1)
      a[i] = 0;
    ans += a[i] + '0';
  }
  cout << ans << endl;
  return 0;
}
