#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
bool ok(int now, int n, int m, int s[], int c[]) {
  string ss = to_string(now);
  if (ss.size() != n) return false;
  for (int i = 0; i < m; i++)
    if ((ss[s[i] - 1] - '0') != c[i]) return false;
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  int now = pow(10, n - 1);
  int s[m], c[m];
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
  while (!ok(now, n, m, s, c)) {
    now++;
    if (now == 1023) break;
  }
  if (now != 1023)
    cout << now << endl;
  else
    cout << -1 << endl;
}
