#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
long long mod = 1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  char ans[N];
  for (int i = 0; i < N; i++) ans[i] = '0';
  for (int i = 0; i < M; i++) {
    int t;
    char c;
    cin >> t >> c;
    if ((t == 1 && c == '0' && N > 1) || ans[t - 1] != '0' && ans[t - 1] != c) {
      cout << "-1" << endl;
      return 0;
    }
    ans[t - 1] = c;
  }
  if (ans[0] == '0' && N > 1) {
    ans[0] = '1';
  } else {
    if (ans[0])
      for (int i = 0; i < N; i++) cout << ans[i];
    cout << endl;
  }
  return 0;
}
