#include typedef struct List { struct List *next; int v; } list; int main() { int i, H, W, N, x[100001], y[100001], num[2][100001] = {}; list *adj[100001] = {}, d[100001], *p; scanf("%d %d %d", &H, &W, &N); for (i = 1; i <= N; i++) { scanf("%d %d", &(x[i]), &(y[i])); num[0][x[i]]++; num[1][y[i]]++; d[i].v = y[i]; d[i].next = adj[x[i]]; adj[x[i]] = &(d[i]); } int j, k, l; for (i = 1; i <= H; i++) { if (num[0][i] <= 1) continue; for (p = adj[i]; p != NULL; p = p->next) if (num[1][p->v] >= 2) break; if (p == NULL) continue; else j = p->v; for (p = p->next; p != NULL; p = p->next) if (num[1][p->v] >= 2) break; if (p == NULL) continue; else k = p->v; break; } if (i > H) printf("-1\n"); else { printf("4\n"); for (l = 1; l <= N; l++) if (x[l] != i && y[l] == j) break; printf("%d", l); for (l = 1; l <= N; l++) if (x[l] == i && y[l] == j) break; printf(" %d", l); for (l = 1; l <= N; l++) if (x[l] == i && y[l] == k) break; printf(" %d", l); for (l = 1; l <= N; l++) if (x[l] != i && y[l] == k) break; printf(" %d\n", l); } fflush(stdout); return 0; }