#include <bits/stdc++.h>
using namespace std;
const int maxn = 11;
int n, m, digit[maxn];
int main() {
  memset(digit, 0, sizeof(digit));
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    digit[s] = c;
  }
  if (n == 1)
    cout << digit[1] << endl;
  else {
    if (digit[1] == 0)
      cout << "-1" << endl;
    else {
      for (int i = 1; i <= n; i++) cout << digit[i];
      cout << endl;
    }
  }
  return 0;
}
