#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
int64 max(int64 a, int64 b) {
  if (b > a)
    return b;
  else
    return a;
}
int64 min(int64 a, int64 b) {
  if (b < a)
    return b;
  else
    return a;
}
signed main() {
  int64 n, m;
  cin >> n >> m;
  vector<int64> s(m), c(m);
  string res = "";
  for (int64 i = 0; i < n; i++) res += "?";
  bool can = true;
  for (int64 i = 0; i < m; i++) {
    int64 s;
    char c;
    cin >> s >> c;
    s--;
    if (res[s] != '?') {
      can = false;
    } else {
      res[s] = c;
    }
  }
  for (int64 i = 0; i < n; i++) {
    if (i == 0 && n != 1) {
      if (res[i] == '0') can = false;
      if (res[i] == '?') res[i] = '1';
    } else {
      if (res[i] == '?') res[i] = '0';
    }
  }
  if (can)
    cout << res << endl;
  else
    cout << -1 << endl;
  return 0;
}
