#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  int *S;
  int s, c;
  int answer;
  cin >> N >> M;
  S = (int *)malloc(sizeof(int) * N);
  for (int i = 0; i < N; i++) {
    S[i] = 0;
  }
  for (int i = 0; i < M; i++) {
    cin >> s;
    cin >> c;
    S[s] = c;
  }
  if (S[N = 1] == 0) {
    answer = -1;
    cout << answer << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    answer = S[i] * 10 * (i + 1);
  }
  cout << answer << endl;
  return 0;
}
