#include <bits/stdc++.h>
using namespace std;
const int N = 1 * 1e6 + 5;
const unsigned long long mod = 1e9 + 7;
const int INF = INT_MAX;
const unsigned long long INFCAD = unsigned long long(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
int v[3][3];
int vis[3][3];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  string ans = string(n, '@');
  bool flag = 1;
  while (n--) {
    int x;
    char y;
    cin >> x >> y;
    x--;
    if (ans[x] != '@') {
      if (ans[x] != y)
        flag = 0;
      else
        ans[x] = y;
    } else
      ans[x] = y;
  }
  if (!flag)
    ans = "-1";
  else {
    if (ans[0] == '@') {
      ans[0] = '1';
      for (int i = 1; i < int(ans.size()); i += 1)
        if (ans[i] == '@') ans[i] = '0';
    } else {
      int i = 0;
      while (i < int(ans.size()) && ans[i] == '0') i++;
      if (ans[i] == '@') ans[i] = '1';
      for (int j = i + 1; j < int(ans.size()); j += 1)
        if (ans[j] == '@') ans[j] = '0';
    }
  }
  cout << ans << '\n';
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  return 0;
}
