#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  int n, m, co = 0, s, c;
  cin >> n >> m;
  vector<int> mp(n);
  for (i = 0; i < n; i++) {
    mp[i] = 0;
  }
  for (i = 0; i < m; i++) {
    cin >> s >> c;
    mp[s - 1]++;
    if (mp[s - 1] > 1)
      ;
    else
      co += pow(10, n - (s)) * c;
  }
  if (co / pow(10, n - 1) < 1) co = -1;
  cout << co << endl;
  return 0;
}
