#include <bits/stdc++.h>
using namespace std;
constexpr int Inf = 1000000000;
constexpr long long INF = 1e18;
constexpr long long MOD = 1000000007;
const double PI = 3.1415926535897;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N, -1);
  bool ret = true;
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    if (vec.at(A - 1) != -1 && vec.at(A - 1) != B) {
      ret = false;
    } else {
      vec.at(A - 1) = B;
    }
  }
  if (N != 1 && vec.at(0) == 0) {
    ret = false;
  }
  if (ret == false) {
    cout << -1 << endl;
  } else {
    for (int i = 0; i < N; i++) {
      if (vec.at(i) == -1) {
        if (i == 0) {
          cout << 1;
        } else {
          cout << 0;
        }
      } else {
        cout << vec.at(i);
      }
    }
  }
  cout << endl;
}
