#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)2e5 + 13;
const long long INFL = 9223372036854775807;
const int INF = 2147483647;
const long long MOD = (int)1e9 + 7, MOD2 = 1e9 + 21;
const long long base = 101, base2 = 37;
const long double pi = 3.1415926535897932;
int num[4];
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  fill(num, num + 4, -1);
  bool ans = 1;
  for (int i = 1; i <= m; ++i) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0) ans = 0;
    if (num[s] == -1)
      num[s] = c;
    else if (num[s] != c)
      ans = 0;
  }
  if (!ans)
    cout << "-1\n";
  else {
    for (int i = 1; i <= n; ++i) {
      if (num[i] == -1) {
        if (i == 1)
          num[i] = 1;
        else
          num[i] = 0;
      }
    }
    for (int i = 1; i <= n; ++i) cout << num[i];
  }
  return 0;
}
