// Arup Guha
// 11/15/2015
// Solution to 2015 SER D1 Problem: Gears

import java.util.*;

public class gears {

	final public static int UNREACHABLE = -1;

	public static void main(String[] args) {

		// Read in gears.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		gear[] list = new gear[n];
		for (int i=0; i<n; i++) {
			int x = stdin.nextInt();
			int y = stdin.nextInt();
			int r = stdin.nextInt();
			list[i] = new gear(x,y,r);
		}

		// Store underlying graph here.
		ArrayList[] graph = new ArrayList[n];
		for (int i=0; i<n; i++)
			graph[i] = new ArrayList<Integer>();

		// Form graph structure by trying all.
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				if (i==j) continue;
				if (list[i].adj(list[j])) graph[i].add(j);
			}
		}

		// Set up BFS.
		int[] dist = new int[n];
		Arrays.fill(dist, UNREACHABLE);
		dist[0] = 0;
		LinkedList<Integer> q = new LinkedList<Integer>();
		q.offer(0);

		// Run it.
		while (q.size() > 0) {

			int next = q.poll();

			// Enqueue all unvisited neighbors, record distance.
			for (int i=0; i<graph[next].size(); i++) {
				int item = ((ArrayList<Integer>)graph[next]).get(i);
				if (dist[item] == -1) {
					dist[item] = dist[next] + 1;
					q.offer(item);
				}
			}
		}

		// Stuck!
		if (!bipartite(graph, dist)) System.out.println(-1);

		// Not connected.
		else if (dist[n-1] == -1) System.out.println(0);

		else {

			// Set the direction and gcd.
			int mult = dist[n-1]%2 == 0 ? 1 : -1;
			int div = gcd(list[0].r, list[n-1].r);

			// Then output.
			System.out.println(list[n-1].r/div+" "+(mult*list[0].r/div));
		}
	}

	// Returns true iff graph is bipartite based on shortest distances in dist.
	public static boolean bipartite(ArrayList[] graph, int[] dist) {

		// Go through each edge.
		for (int i=0; i<graph.length; i++) {
			for (int j=0; j<graph[i].size(); j++) {
				int item = ((ArrayList<Integer>)graph[i]).get(j);
				if (dist[item] == -1) continue;

				// This proves that the graph isn't bipartite...
				if ((dist[i]-dist[item])%2 == 0)
					return false;
			}
		}

		// If we get here, it must be.
		return true;
	}

	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a%b);
	}
}

class gear {

	public int x;
	public int y;
	public int r;

	public gear(int myx, int myy, int myr) {
		x = myx;
		y = myy;
		r = myr;
	}

	public boolean adj(gear other) {
		return (x-other.x)*(x-other.x) + (y-other.y)*(y-other.y) == (r+other.r)*(r+other.r);
	}
}