#include <bits/stdc++.h>
using namespace std;
void fnInput(string& rsNum, int& nDigit, bool& rbRslt) {
  int nInfSiz;
  cin >> nDigit >> nInfSiz;
  rsNum.resize(nDigit, ' ');
  rbRslt = true;
  for (int i = 0; i < nInfSiz; i++) {
    int nPos, nNum;
    cin >> nPos >> nNum;
    if (nPos == 1 && nNum == 0 && nDigit > 1)
      rbRslt = false;
    else if (rsNum[nPos - 1] == ' ')
      rsNum[nPos - 1] = ('0' + nNum);
    else if (rsNum[nPos - 1] != ('0' + nNum))
      rbRslt = false;
    else
      continue;
  }
  return;
}
string fnNumstrGet(string sNum) {
  for (int i = 0; i < sNum.size(); i++)
    if (sNum[i] == ' ')
      if (!i)
        sNum = '1';
      else
        sNum = '0';
  return sNum;
}
int main() {
  string sNum;
  int nDigit;
  bool bRslt;
  fnInput(sNum, nDigit, bRslt);
  if (!bRslt) {
    cout << "-1" << endl;
    return 0;
  }
  cout << fnNumstrGet(sNum) << endl;
  return 0;
}
