#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  string s(N, 'a');
  while (M--) {
    int pos, val;
    cin >> pos >> val;
    if (s[pos - 1] == 'a' || s[pos - 1] == val + '0')
      s[pos - 1] = val + '0';
    else
      return cout << -1, 0;
  }
  if (s[0] == 'a') s[0] = '1';
  for (int i = 1; i < N; i++)
    if (s[i] == 'a') s[i] = '0';
  cout << s;
}
