#include <bits/stdc++.h>
using namespace std;
long long linp() {
  long long x;
  scanf("%lld", &x);
  return x;
}
long long mod(long long i) {
  long long mi = i % 1000000007;
  if (mi < 0) mi += 1000000007;
  return mi;
}
long long gcd(long long i, long long j) {
  if (j != 0)
    return gcd(j, i % j);
  else
    return i;
}
pair<long long, long long> extgcd(long long a, long long b) {
  pair<long long, long long> ans;
  if (b != 0) {
    pair<long long, long long> next = extgcd(b, a % b);
    ans.first = next.second;
    ans.second = next.first - (a / b) * next.second;
  } else {
    ans = pair<long long, long long>(1, 0);
  }
  return ans;
}
long long division(long long a, long long b, long long m) {
  return mod(mod(a) * mod(extgcd(b, m).first));
}
long long numperm_mod(long long x, long long y) {
  long long res = 1;
  for (long long i = x; i >= y; i--) {
    res = mod(res * mod(i));
  }
  return mod(res);
}
long long numperm(long long x, long long y) {
  long long res = 1;
  for (long long i = x; i >= y; i--) {
    res *= i;
  }
  return res;
}
long long pow_mod(long long x, long long y) {
  x = mod(x);
  if (y == 1) {
    return mod(x);
  }
  long long res = mod(pow_mod(mod(x * x), y / 2));
  if (y % 2 == 0) {
    return res;
  } else {
    return mod(x * res);
  }
}
long long pow(long long x, long long y) {
  if (y == 1) {
    return x;
  }
  if (y % 2 == 0) {
    return pow(x * x, y / 2);
  } else {
    return x * pow(x * x, y / 2);
  }
}
vector<long long> Eratosthenes(long long n) {
  bool isPrime[n];
  fill(isPrime, isPrime + n, true);
  isPrime[0] = isPrime[1] = false;
  for (long long i = 2; i < sqrt(n) + 1; i++) {
    if (isPrime[i]) {
      for (long long j = 2 * i; j <= n; j += i) {
        isPrime[j] = false;
      }
    }
  }
  vector<long long> P;
  for (long long i = 2; i < n + 1; i++) {
    if (isPrime[i]) {
      P.push_back(i);
    }
  }
  return P;
}
struct edge {
  long long to, cost;
  double dcost;
};
struct vertex {
  long long key;
  double dkey;
  vector<edge> edges;
};
class Graph {
 public:
  long long V;
  vertex* vertices;
  Graph(long long v) {
    V = v;
    vertices = new vertex[V];
    for (long long i = 0; i < V; i++) {
      vertices[i].key = -1;
      vertices[i].dkey = -1;
    }
  }
  void setDE(long long i, long long j, long long cos) {
    edge e;
    e.to = j;
    e.cost = cos;
    vertices[i].edges.push_back(e);
    return;
  }
  void setDE(long long i, long long j, double dcos) {
    edge e;
    e.to = j;
    e.dcost = dcos;
    vertices[i].edges.push_back(e);
    return;
  }
  void setUDE(long long i, long long j, long long cos) {
    edge ei, ej;
    ei.to = j;
    ej.to = i;
    ei.cost = ej.cost = cos;
    vertices[i].edges.push_back(ei);
    vertices[j].edges.push_back(ej);
    return;
  }
  void setUDE(long long i, long long j, double dcos) {
    edge ei, ej;
    ei.to = j;
    ej.to = i;
    ei.dcost = ej.dcost = dcos;
    vertices[i].edges.push_back(ei);
    vertices[j].edges.push_back(ej);
    return;
  }
  void setKey(long long i, long long newKey) { vertices[i].key = newKey; }
  void setKey(long long i, double newKey) { vertices[i].key = newKey; }
  edge getEdge(long long i, long long j) {
    for (long long a = 0; a < vertices[i].edges.size(); a++) {
      if (vertices[i].edges[a].to == j) {
        return vertices[i].edges[a];
      }
    }
    return (edge){j, LLONG_MAX / 2, DBL_MAX / 2};
  }
  void bellman_ford(long long s, long long b[]) {
    fill(b, b + V, LLONG_MAX / 2);
    b[s] = 0;
    while (true) {
      bool update = false;
      for (long long i = 0; i < V; i++) {
        for (long long j = 0; j < vertices[i].edges.size(); j++) {
          edge e = vertices[i].edges[j];
          if (b[e.to] > b[i] + e.cost) {
            b[e.to] = b[i] + e.cost;
            update = true;
          }
        }
      }
      if (!update) break;
    }
    return;
  }
  void dijkstra(long long s, long long d[]) {
    priority_queue<pair<long long, long long>,
                   vector<pair<long long, long long>>,
                   greater<pair<long long, long long>>>
        que;
    fill(d, d + V, LLONG_MAX / 2);
    d[s] = 0;
    que.push(pair<long long, long long>(0, s));
    while (!que.empty()) {
      pair<long long, long long> p = que.top();
      que.pop();
      long long v = p.second;
      if (d[v] < p.first) continue;
      for (long long i = 0; i < vertices[v].edges.size(); i++) {
        edge e = vertices[v].edges[i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(pair<long long, long long>(d[e.to], e.to));
        }
      }
    }
    return;
  }
  void warshall_floyd(long long** w) {
    for (long long i = 0; i < V; i++) {
      for (long long j = 0; j < V; j++) {
        w[i][j] = LLONG_MAX / 2;
      }
    }
    for (long long i = 0; i < V; i++) {
      for (long long j = 0; j < vertices[i].edges.size(); j++) {
        w[i][vertices[i].edges[j].to] = vertices[i].edges[j].cost;
      }
    }
    for (long long i = 0; i < V; i++) {
      w[i][i] = 0;
    }
    for (long long i = 0; i < V; i++) {
      for (long long j = 0; j < V; j++) {
        for (long long k = 0; k < V; k++) {
          w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
        }
      }
    }
  }
};
class UF {
 public:
  long long N;
  long long* par;
  long long* rank;
  UF(long long n) {
    N = n;
    par = new long long[N];
    rank = new long long[N];
    for (long long i = 0; i < N; i++) {
      par[i] = i;
      rank[i] = i;
    }
    return;
  }
  long long root(long long x) {
    if (x == par[x])
      return x;
    else
      return par[x] = root(par[x]);
  }
  bool same(long long x, long long y) { return (root(x) == root(y)); }
  void Union(long long x, long long y) {
    long long rtx = root(x);
    long long rty = root(y);
    if (rank[rtx] < rank[rty]) {
      par[rtx] = rty;
    } else {
      par[rty] = rtx;
      if (rank[rtx] == rank[rty]) {
        rank[rtx]++;
      }
    }
  }
};
class ST {};
long long solveA() {
  long long N;
  cin >> N;
  cout << (N + 1) / 2;
  return 0;
}
long long solveB() {
  pair<long long, bool> A[3][3];
  for (long long i = 0; i < 3; i++) {
    for (long long j = 0; j < 3; j++) {
      cin >> A[i][j].first;
      A[i][j].second = false;
    }
  }
  long long N = linp();
  long long b;
  for (long long i = 0; i < N; i++) {
    cin >> b;
    for (long long j = 0; j < 3; j++) {
      for (long long k = 0; k < 3; k++) {
        if (A[j][k].first == b) A[j][k].second = true;
      }
    }
  }
  if ((A[0][0].second && A[1][1].second && A[2][2].second) ||
      (A[0][2].second && A[1][1].second && A[2][0].second) ||
      (A[0][0].second && A[0][1].second && A[0][2].second) ||
      (A[1][0].second && A[1][1].second && A[1][2].second) ||
      (A[2][0].second && A[2][1].second && A[2][2].second) ||
      (A[0][0].second && A[1][0].second && A[2][0].second) ||
      (A[0][1].second && A[1][1].second && A[2][1].second) ||
      (A[0][2].second && A[1][2].second && A[2][2].second))
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
long long solveC() {
  long long N, M;
  cin >> N >> M;
  string ans(N, 'E');
  long long s, c;
  for (long long i = 0; i < M; i++) {
    cin >> s >> c;
    if (ans[s - 1] == 'E') {
      ans[s - 1] = c + '0';
    } else if (ans[s - 1] != c + '0') {
      cout << "-1";
      return 0;
    }
  }
  for (long long i = 0; i < N; i++) {
    if (i == 0 && ans[i] == '0' && N != 1) {
      cout << "-1";
      return 0;
    } else if (ans[i] == 'E') {
      if (i == 0) {
        ans[i] = '1';
      } else {
        ans[i] = '0';
      }
    }
  }
  cout << stoi(ans);
  return 0;
}
long long solveD() { return 0; }
long long solveE() { return 0; }
signed main() {
  solveC();
  return 0;
}
