#include <bits/stdc++.h>
using namespace std;
int x[100];
bool y[100];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    if (n == 1)
      cout << 0;
    else {
      cout << 1;
      for (int i = 2; i <= n; i++) cout << 0;
    }
    return 0;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    x[a] = min(b, x[a]), y[a] = true;
  }
  if (x[1] == 0) {
    cout << "-1";
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (!y[i]) {
      if (i == 1)
        cout << "1";
      else
        cout << "0";
    } else
      cout << x[i];
  }
  return 0;
}
