#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int index[m], value[m];
  for (int i = 0; i < m; i++) {
    cin >> index[i] >> value[i];
  }
  int k;
  k = pow(10, (n - 1));
  int final = pow(10, (n)) - 1;
  int flag = 1;
  for (; k <= final; k++) {
    stringstream ss;
    ss << k;
    string s;
    ss >> s;
    flag = 1;
    for (int i = 0; i < m; i++) {
      if ((s[index[i] - 1] - 48) != value[i]) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      cout << s << "\n";
      break;
    }
  }
  if (!flag) cout << "-1\n";
  return 0;
}
