#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int s[M];
  int c[M];
  for (int i = 0; i < (M); ++i) cin >> s[i] >> c[i];
  int num[N];
  for (int i = 0; i < (N); ++i) num[i] = -1;
  for (int i = 0; i < (M); ++i) {
    if ((num[s[i] - 1] == -1) || (num[s[i] - 1] == c[i])) {
      num[s[i] - 1] = c[i];
      if ((c[i] == 0) && (s[i] == 1)) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < (N); ++i) {
    if (num[i] == -1) {
      if (i == 0) {
        num[i] = 1;
      } else {
        num[i] = 0;
      }
    }
  }
  for (int i = 0; i < (N); ++i) cout << num[i];
  cout << endl;
  return 0;
}
