#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  for (int i = 0; i < M; i++) cin >> s[i] >> c[i];
  for (int i = 0; i < M; i++) s[i]--;
  vector<int> ans(N);
  for (int i = 0; i < N; i++) ans[i] = 0;
  for (int i = 0; i < M; i++) ans[s[i]] = c[i];
  int x = 0;
  for (int i = 0; i < N; i++) {
    x += ans[i] * pow(10, N - i - 1);
  }
  int a = 1;
  if (a = 1) {
    cout << -1 << endl;
  } else {
    if (N == 1) {
      cout << x << endl;
    } else {
      if (ans[0] == 0) {
        cout << -1 << endl;
      } else {
        cout << x << endl;
      }
    }
  }
  return 0;
}
