#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long s[m];
  long long c[m];
  long long h[n];
  vector<char> cs(n, '0');
  string ans;
  for (int i = 0; i < (m); i++) {
    cin >> s[i] >> c[i];
    cs[--s[i]] = c[i] + '0';
  }
  if (cs[n - 1] == '0') {
    cout << -1 << endl;
    return 0;
  }
  for (char tmp : cs) ans.push_back(tmp);
  cout << ans << endl;
  return 0;
}
