#include <bits/stdc++.h>
using namespace std;
long long int s[500005];
long long int c[500005];
long long int nmbr[500005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int m, n, i, j, k, l;
  cin >> n >> m;
  for (i = 1; i <= n; i++) nmbr[i] = -1;
  int flag = 0;
  for (i = 1; i <= m; i++) {
    cin >> k >> l;
    if (nmbr[k] != -1 && nmbr[k] != l) {
      flag = 1;
      break;
    } else if (k == 1 && l == 0 && n > 1) {
      flag = 1;
      break;
    } else
      nmbr[k] = l;
  }
  if (flag == 0) {
    for (i = 1; i <= n; i++) {
      if (nmbr[i] == -1) {
        if (i == 1)
          nmbr[i] = 1;
        else
          nmbr[i] = 0;
      }
    }
    for (i = 1; i <= n; i++) cout << nmbr[i];
  } else
    cout << "-1";
  return 0;
}
