#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> data(N, -1);
  for (int i = 0; i < (int)(M); i++) {
    int si, ci;
    cin >> si >> ci;
    if (data[si - 1] == -1) {
      data[si - 1] = ci;
    } else {
      if (data[si - 1] != ci) {
        cout << "-1" << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < (int)(N); i++) {
    if (i == 0) {
      if (data[i] == 0) {
        cout << "-1" << endl;
        return 0;
      }
      if (data[i] == -1) {
        data[i] = 1;
      }
    } else {
      if (data[i] == -1) {
        data[i] = 0;
      }
    }
  }
  for (int x : data) {
    cout << x;
  }
  cout << endl;
  return 0;
}
