#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[2][m];
  for (int i = 0; i < m; i++) {
    int k, l;
    cin >> k >> l;
    a[0][i] = k;
    a[1][i] = l;
  }
  int b[n];
  b[0] = 1;
  bool ans = true;
  for (int i = 1; i < n; i++) b[i] = 0;
  for (int i = 0; i < m - 1; i++) {
    for (int j = i + 1; j < m; j++) {
      if (a[0][i] == a[0][j] && a[1][i] != a[1][j]) ans = false;
    }
  }
  for (int i = 0; i < m; i++) {
    b[a[0][i] - 1] = a[1][i];
  }
  if (b[0] == 0) ans = false;
  if (ans) {
    for (int i = 0; i < n; i++) {
      cout << b[i];
    }
    cout << endl;
  } else
    cout << -1 << endl;
}
