#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  int menge, gr, numm, nummer;
  cin >> gr >> menge;
  string s;
  for (int i = 0; i < gr; i++) {
    s += '0';
  }
  s[0] = '1';
  bool can = false;
  for (int i = 0; i < menge; i++) {
    cin >> numm >> nummer;
    numm--;
    if (s[numm] != '0' && s[numm] != (char)nummer + '0' && numm != 0) {
      cout << -1;
      return 0;
    }
    if (numm == 0 && can == true) {
      if (s[numm] != (char)nummer + '0') {
        cout << -1;
        return 0;
      }
    }
    if (numm == 0 && can == false) {
      can = true;
    }
    if (numm == 0 && nummer == 0) {
      cout << -1;
      return 0;
    }
    s[numm] = (char)nummer + '0';
  }
  cout << s;
  return 0;
}
