#include <bits/stdc++.h>
using namespace std;
bool check(vector<vector<bool>> B) {
  for (int i = 0; i < 3; i++) {
    if (B[i][0] && B[i][1] && B[i][2]) return true;
  }
  for (int i = 0; i < 3; i++) {
    if (B[0][i] && B[1][i] && B[2][i]) return true;
  }
  if (B[0][0] && B[1][1] && B[2][2]) return true;
  if (B[0][2] && B[1][1] && B[2][0]) return true;
  return false;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(n, -1);
  vector<vector<int>> B(m, vector<int>(2, -1));
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    B[i][0] = a;
    B[i][1] = b;
  }
  for (int i = 0; i < m; i++) {
    if (B[i][0] > n) {
      cout << "-1" << endl;
      return 0;
    }
    if (B[i][0] == 1 && B[i][1] == 0) {
      cout << "-1" << endl;
      return 0;
    }
    if (A[B[i][0] - 1] == -1)
      A[B[i][0] - 1] = B[i][1];
    else {
      if (A[B[i][0] - 1] != B[i][1]) {
        cout << "-1" << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (A[0] == -1)
      A[0] = 1;
    else if (A[i] == -1)
      A[i] = 0;
  }
  string s = "";
  for (int i = 0; i < n; i++) {
    s += to_string(A[i]);
  }
  cout << s << endl;
  return 0;
}
