#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  int num[100];
  bool flg = false;
  for (int i = 0; i < 100; i++) {
    num[i] = -1;
  }
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (num[s] == -1) {
      if (s == 0 && c == 0) {
        flg = true;
      } else {
        num[s] = c;
      }
    } else {
      if (num[s] != c) {
        flg = true;
      }
    }
  }
  if (flg == true) {
    cout << "-1" << endl;
  } else {
    for (int i = 0; i < N; i++) {
      if (num[i] == -1) {
        if (i == 0 && N > 1) {
          cout << "1";
        } else {
          cout << "0";
        }
      } else {
        cout << num[i];
      }
    }
    cout << endl;
  }
}
