#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> p(N);
  int z = 0;
  for (int i = 0; i < N; i++) {
    p.at(i) = -1;
  }
  for (int i = 0; i < M; i++) {
    int c, a;
    cin >> c >> a;
    if (p.at(c - 1) == -1) {
      p.at(c - 1) = a;
    } else if (a != p.at(c - 1)) {
      z = -1;
      break;
    }
  }
  if (z == 0 && p.at(0) != 0 && p.at(0) != -1) {
    for (int i = 0; i < N; i++) {
      if (p.at(i) == -1) {
        cout << "0";
      } else {
        cout << p.at(i);
      }
    }
    cout << endl;
  } else if (z == 0 && p.at(0) == -1) {
    cout << "1";
    for (int i = 1; i < N; i++) {
      if (p.at(i) == -1) {
        cout << "0";
      } else {
        cout << p.at(i);
      }
    }
    cout << endl;
  } else {
    cout << "-1" << endl;
  }
}
