#include <bits/stdc++.h>
using namespace std;
int getSdigit(int test, int s, int N) {
  int altS;
  altS = N + 1 - s;
  for (int i = 0; i < altS - 1; i++) {
    test = test / 10;
  }
  return (test % 10);
}
bool check(int test, int s, int c, int N) {
  if (getSdigit(test, s, N) == c) {
    return true;
  } else {
    return false;
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s, c;
  for (int i = 0; i < M; i++) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    s.push_back(tmp1);
    c.push_back(tmp2);
  }
  bool flag2 = false;
  for (int test = (int)pow(10, (N - 1)); test < (int)pow(10, N); test++) {
    bool flag = true;
    for (int i = 0; i < M; i++) {
      if (check(test, s[i], c[i], N) == false) {
        flag = false;
        continue;
      }
    }
    if (flag == true) {
      cout << test << endl;
      flag2 = true;
      break;
    }
  }
  if (flag2 == false) {
    cout << -1 << endl;
  }
  return 0;
}
