#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int mp[100];
  for (int i = 0; i < 100; i++) mp[i] = 200;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    int f = min(mp[a], b);
    mp[a] = f;
  }
  string ans;
  for (int i = 1; i <= n; i++) {
    if (mp[i] == 200)
      ans += '0';
    else
      ans += (char)(mp[i] + '0');
  }
  if (ans[0] == '0')
    cout << -1 << endl;
  else
    cout << ans << endl;
}
