#include <bits/stdc++.h>
using namespace std;
int N, M;
int jyou(int x) {
  int tmp = 1;
  for (int i = 0; i < x; i++) {
    tmp *= 10;
  }
  return tmp;
}
int main() {
  cin >> N >> M;
  map<int, int> jyouken;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    if (jyouken.count(a) != 0) {
      if (jyouken[a] > b) jyouken[a] = b;
    } else {
      jyouken[a] = b;
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += jyouken[i] * jyou(N - i);
  }
  if (ans == 0) {
    cout << -1 << endl;
    return 0;
  } else
    cout << ans << endl;
  return 0;
}
