#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M = 0;
  cin >> N >> M;
  if (N == 1 && M == 0) {
    cout << 0;
    return 0;
  }
  int s[M];
  int c[M];
  int ans[N];
  int flag[N];
  for (int i = 0; i < (N); i++) {
    ans[N] = 0;
    flag[i] = 0;
  }
  for (int i = 0; i < (M); i++) {
    cin >> s[i] >> c[i];
    int index = s[i] - 1;
    if (flag[index] == 1 && c[i] != ans[index]) {
      cout << -1;
      return 0;
    } else if (s[i] == 1 && c[i] == 0) {
      cout << -1;
      return 0;
    }
    ans[index] = c[i];
    flag[index] = 1;
  }
  for (int i = 0; i < (N); i++) {
    if (flag[i] == 0) {
      if (i == 0)
        ans[i] = 1;
      else
        ans[i] = 0;
    }
  }
  for (int i = 0; i < (N); i++) cout << ans[i];
  cout << endl;
}
