#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ans(N, -1);
  bool res = true;
  for (int i = (int)(0); i < (int)(M); i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (ans[s] != -1 && ans[s] != c) {
      res = false;
    } else {
      ans[s] = c;
    }
  }
  if (res) {
    if (ans[0] == 0)
      cout << -1 << endl;
    else {
      bool flag = true;
      for (int i = (int)(0); i < (int)(N); i++) {
        if (ans[i] == -1) {
          if (flag) {
            cout << 1;
            flag = false;
          } else {
            cout << 0;
          }
        } else {
          cout << ans[i];
          flag = false;
        }
      }
      cout << endl;
    }
  } else {
    cout << -1 << endl;
  }
  return 0;
}
