#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int s[m + 1];
  memset(s, -1, m + 1);
  int a, b;
  int flag = 0;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if (s[a] == -1) {
      s[a] = b;
    } else {
      if (s[a] != b) flag = 1;
    }
  }
  if (flag == 1)
    cout << -1 << endl;
  else {
    if (s[1] == 0) {
      cout << -1 << endl;
    } else {
      for (int i = 1; i <= n; i++) {
        if (s[i] != -1 && i <= m)
          cout << s[i];
        else if (i == 1)
          cout << 1;
        else
          cout << 0;
      }
      cout << endl;
    }
  }
}
