#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << "1";
    for (int y = 1; y < n; y++) {
      cout << "0";
    }
  } else {
    char c[n];
    for (int j = 0; j < n; j++) {
      c[j] = '!';
    }
    int a[m][2], flag = 0;
    for (int i = 0; i < m; i++) {
      scanf("%d %d", &a[i][0], &a[i][1]);
    }
    for (int p = 0; p < m; p++) {
      if (((c[a[p][0] - 1]) == '!') || ((c[a[p][0] - 1]) == '0' + a[p][1]))
        c[a[p][0] - 1] = '0' + a[p][1];
      else if (c[a[p][0] - 1] != '0' + a[p][1]) {
        flag = 1;
        break;
      }
    }
    if (c[0] == '0' && n > 1)
      flag = 1;
    else if (c[0] == '!')
      c[0] = '1';
    if (flag)
      cout << "-1" << endl;
    else {
      for (int x = 0; x < n; x++) {
        if (c[x] == '!')
          cout << "0";
        else
          cout << c[x];
      }
    }
  }
}
