#include <bits/stdc++.h>
using namespace std;
map<int, int> a;
int main() {
  int m, n, k[10][2];
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> k[i][0] >> k[i][1];
    if ((a[k[i][0] - 1] != 0 && a[k[i][0] - 1] != k[i][1]) ||
        k[i][0] - 1 == 0 && k[i][1] == 0) {
      cout << "-1";
      return 0;
    } else
      a[k[i][0] - 1] = k[i][1];
  }
  if (m == 0) {
    cout << pow(10, n - 1);
    return 0;
  }
  if (n == 1) {
    cout << a[0];
  }
  if (n == 2) {
    if (a[0] == 0) a[0] = 1;
    cout << a[0] << a[1];
  }
  if (n == 3) {
    if (a[0] == 0) a[0] = 1;
    cout << a[0] << a[1] << a[2];
  }
  return 0;
}
