#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int s[m];
  int c[m];
  for (int i = 1; i <= m; i++) cin >> s[i] >> c[i];
  int a[n];
  for (int i = 1; i <= n; i++) a[i] = 0;
  for (int i = 1; i <= m; i++) {
    a[s[i]] = c[i];
  }
  if (n != 1 && a[1] == 0) {
    cout << "-1" << endl;
  } else {
    for (int i = 1; i <= n; i++) cout << a[i];
    cout << endl;
  }
}
