#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s, c;
  cin >> n >> m;
  int l[3] = {-1, -1, -1};
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if ((n != 1 && s == 1 && c == 0) || (l[s - 1] != -1 && c != l[s - 1])) {
      cout << -1 << endl;
      return 0;
    } else
      l[s - 1] = c;
  }
  if (l[0] == -1) l[0] = 1;
  if (l[1] == -1) l[1] = 0;
  if (l[2] == -1) l[2] = 0;
  string ans;
  for (int i = 0; i < n; i++) ans += ('0' + l[i]);
  cout << ans << endl;
}
