#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long INFL = 0x3f3f3f3f3f3f3f3f;
char C[2];
char ans[5];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (m); i++) {
    int a;
    scanf("%d%s", &a, C);
    a--;
    char c = C[0];
    if (ans[a] && ans[a] != c) {
      puts("-1");
      return 0;
    }
    ans[a] = c;
  }
  if (ans[0] == '0') {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < (n); i++) {
    if (!ans[i]) {
      if (i == 0)
        ans[i] = '1';
      else
        ans[i] = '0';
    }
  }
  cout << ans << endl;
}
