#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M; cin >> N >> M;
  int s[5], c[5]; for (int i = 0; i < M; i++) {cin >> s[i] >> c[i]; s[i]--;}

  for (int i = 0; i <= 999; i++) {
    string x = to_string(i);

    if (x.size() != N) {
      continue;
    }

    bool ok = true;
    for (int j = 0; j < M; j++) {
      if (x[s[j]] != (char)(c[j] + '0')) {
        ok = false;
        break;
      }
    }

    if (ok) {
      cout << x << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}