← Home
```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	readInt := func() int {
		scanner.Scan()
		x := 0
		for _, b := range scanner.Bytes() {
			x = x*10 + int(b-'0')
		}
		return x
	}

	n := readInt()
	m := readInt()

	g := make(map[int]map[int]bool)
	for i := 0; i < m; i++ {
		u := readInt()
		v := readInt()
		if g[u] == nil {
			g[u] = make(map[int]bool)
		}
		if g[v] == nil {
			g[v] = make(map[int]bool)
		}
		g[u][v] = true
		g[v][u] = true
	}

	degrees := make([]int, n+1)
	newGraph := make(map[int]map[int]bool)
	active := make(map[int]bool)
	for i := 1; i <= n; i++ {
		active[i] = true
	}

	result := make([][2]int, 0, m)

	for len(result) < m {
		u := -1
		for v := range active {
			u = v
			break
		}
		if u == -1 {
			fmt.Println(-1)
			return
		}

		v := -1
		for w := range active {
			if u == w {
				continue
			}
			if g[u] != nil && g[u][w] {
				continue
			}
			if newGraph[u] != nil && newGraph[u][w] {
				continue
			}
			v = w
			break
		}

		if v == -1 {
			fmt.Println(-1)
			return
		}

		result = append(result, [2]int{u, v})
		if newGraph[u] == nil {
			newGraph[u] = make(map[int]bool)
		}
		if newGraph[v] == nil {
			newGraph[v] = make(map[int]bool)
		}
		newGraph[u][v] = true
		newGraph[v][u] = true
		degrees[u]++
		degrees[v]++
		if degrees[u] == 2 {
			delete(active, u)
		}
		if degrees[v] == 2 {
			delete(active, v)
		}
	}

	for _, e := range result {
		fmt.Println(e[0], e[1])
	}
}
```