#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
map<int, int> mop, what;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (mop[x] && what[x] != y) {
      puts("-1");
      return 0;
    }
    mop[x] = 1;
    what[x] = y;
  }
  string ans = "";
  for (int i = 1; i <= n; i++) {
    if (i == 1 && mop[i] && what[i] == 0) {
      puts("-1");
      return 0;
    }
    if (mop[i] == 0) {
      if (i == 1) {
        ans += "1";
      } else {
        ans += "0";
      }
    } else {
      ans += (char)(what[i] + '0');
    }
  }
  cout << ans << '\n';
  return 0;
}
