#include <bits/stdc++.h>
using namespace std;
const long long MOD = long long(1e9 + 7);
const long long INF = long long(1e18) + 7;
long long P_POW(long long i, long long n) {
  if (n == 0) return 1;
  n--;
  long long rep = i;
  while (n) {
    rep = rep * i;
    n--;
  }
  return rep;
}
unsigned GetDigit(unsigned num) {
  unsigned digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}
unsigned binarySearch(long long target, long long max, long long min) {
  while ((max - min) > 1) {
    if ((max + min) / 2 > target) {
      max = (max + min) / 2;
      min = min;
    } else {
      max = max;
      min = (max + min) / 2;
    }
  }
}
void f(int rest, string s) {
  char abc[] = "abc";
  if (rest == 0) {
    cout << s << endl;
  } else {
    for (int i = 0; i < 3; i++) {
      f(rest - 1, s + abc[i]);
    }
  }
}
long long h, w;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
long long dfs(long long ox, long long oy, vector<vector<char>> v,
              vector<vector<int>> dist) {
  int m = 0;
  for (int i = 0; i < 4; i++) {
    int nx = ox + dx[i], ny = oy + dy[i];
    if (nx < 0 || nx >= w || ny < 0 || nx >= h) continue;
    if (v[nx][ny] != '.') continue;
    if (dist[nx][ny] == -1) {
      dist[nx][ny] = dist[ox][oy] + 1;
      dist[nx][ny] = min(dist[ox][oy], dist[nx][ny]);
      cout << "v[nx][ny]: " << dist[nx][ny] << endl;
      dfs(nx, ny, v, dist);
    }
    m = max(m, dist[nx][ny]);
  }
  return m;
}
int bfs2(const vector<string> &v, int x, int y) {
  int H = v.size(), W = v[0].size();
  vector<vector<int>> dist(H, vector<int>(W, -1));
  queue<pair<int, int>> que;
  int res = 0;
  que.push({x, y});
  dist[x][y] = 0;
  while (!que.empty()) {
    int x = que.front().first, y = que.front().second;
    res = max(res, dist[x][y]);
    que.pop();
    cout << "-------" << endl;
    cout << "(x, y)"
         << "(" << x << "," << y << ")" << endl;
    for (int dir = 0; dir < 4; ++dir) {
      int nx = x + dx[dir], ny = y + dy[dir];
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (v[nx][ny] == '#') continue;
      if (dist[nx][ny] == -1) {
        cout << "(nx, ny)"
             << "(" << nx << "," << ny << ")" << endl;
        dist[nx][ny] = dist[x][y] + 1;
        que.push({nx, ny});
      }
    }
  }
  return res;
}
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> v(N, 0);
  long long s, c;
  for (long long i = 0; i < M; i++) {
    cin >> s >> c;
    v.at(s - 1) = c;
  }
  string st = "";
  for (long long i = 0; i < N; i++) {
    st = st + to_string(v[i]);
  }
  if (st[0] == '0')
    cout << "-1" << endl;
  else
    cout << st << endl;
}
