#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s[6], c[6];
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
  for (int i = (int)pow(10, n - 1); i <= (int)pow(10, n) - 1; i++) {
    bool check = true;
    string str = to_string(i);
    for (int j = 0; j < m; j++) {
      if (str[s[j] - 1] - '0' != c[j]) check = false;
    }
    if (check) {
      cout << i;
      return 0;
    }
  }
  cout << "-1";
  return 0;
}
