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