#include <bits/stdc++.h>
using namespace std;
int N, M, s;
bool ok;
char c;
int main() {
  cin >> N >> M;
  string ans = string(N, 'x');
  ok = true;
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    cin >> s >> c;
    --s;
    if (ans[s] == 'x') {
      ans[s] = c;
    } else if (ans[s] != c) {
      ok = false;
      break;
    }
  }
  if (N > 1 && ans[0] == '0') {
    ok = false;
  }
  if (ok) {
    if (ans[0] == 'x') {
      ans[0] = '1';
    }
    for (int i = 1; i < N; ++i) {
      if (ans[i] == 'x') {
        ans[i] = '0';
      }
    }
    cout << ans << "\n";
  } else {
    cout << "-1\n";
  }
}
