#include <bits/stdc++.h>
const int INF = 1001001001;
using namespace std;
long long dp[110][100010];
int main() {
  int n, m;
  cin >> n >> m;
  int ff[m];
  char cc[m];
  for (int i = 0; i < (m); ++i) cin >> ff[i] >> cc[i];
  int s = pow(10, n - 1);
  if (s == 1) s = 0;
  for (int j = s; j < s * 10; j++) {
    string ss = to_string(j);
    bool is = true;
    for (int i = 0; i < (m); ++i) {
      if ((int)ss[ff[i] - 1] != (int)cc[i]) {
        is = false;
      }
    }
    if (is) {
      cout << ss << endl;
      ;
      return 0;
    }
  }
  cout << -1 << endl;
  ;
}
