Problem: Valera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose lower left corner is located at point with coordinates (0, 0) and the length of the side equals a meters. The sides of the square are parallel to coordinate axes.

As the length of the marathon race is very long, Valera needs to have extra drink during the race. The coach gives Valera a bottle of drink each d meters of the path. We know that Valera starts at the point with coordinates (0, 0) and runs counter-clockwise. That is, when Valera covers a meters, he reaches the point with coordinates (a, 0). We also know that the length of the marathon race equals nd + 0.5 meters. 

Help Valera's coach determine where he should be located to help Valera. Specifically, determine the coordinates of Valera's positions when he covers d, 2·d, ..., n·d meters.

Input

The first line contains two space-separated real numbers a and d (1 ≤ a, d ≤ 105), given with precision till 4 decimal digits after the decimal point. Number a denotes the length of the square's side that describes the stadium. Number d shows that after each d meters Valera gets an extra drink.

The second line contains integer n (1 ≤ n ≤ 105) showing that Valera needs an extra drink n times.

Output

Print n lines, each line should contain two real numbers xi and yi, separated by a space. Numbers xi and yi in the i-th line mean that Valera is at point with coordinates (xi, yi) after he covers i·d meters. Your solution will be considered correct if the absolute or relative error doesn't exceed 10 - 4.

Note, that this problem have huge amount of output data. Please, do not use cout stream for output in this problem.

Examples

Input

2 5
2


Output

1.0000000000 2.0000000000
2.0000000000 0.0000000000


Input

4.147 2.8819
6


Output

2.8819000000 0.0000000000
4.1470000000 1.6168000000
3.7953000000 4.1470000000
0.9134000000 4.1470000000
0.0000000000 2.1785000000
0.7034000000 0.0000000000

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		double a = in.nextDouble();
		double d = in.nextDouble();
		int n = in.nextInt();
		StringBuilder sb = new StringBuilder();
		for(int i = 1; i <= n; ++i) {
			double len = i * d - Math.floor(i * d / (4 * a)) * 4 * a;
			if(len < a) {
				sb.append(len);
				sb.append(" 0\n");
			} else if(len < 2 * a) {
				sb.append(a);
				sb.append(' ');
				sb.append(len - a);
				sb.append('\n');
			} else if(len < 3 * a) {
				sb.append(3 * a - len);
				sb.append(' ');
				sb.append(a);
				sb.append('\n');
			} else {
				sb.append("0 ");
				sb.append(4 * a - len);
				sb.append('\n');
			}
		}
		
		System.out.println(sb);
	}

}

// ///////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////

class Fun {
	
	public static long power(long n, long e) {
		long result = 1;
		for(long i = 0; i < e; ++i) {
			result *= n;
		}
		return result;
	}
	
	public static int[] nextInts(Scanner in, int count) {
		int[] result = new int[count];
		for (int i = 0; i < count; ++i) {
			result[i] = in.nextInt();
		}
		return result;
	}
	
	public static boolean isPrime(int n) {
		boolean result = true;
		for(int i = 2; i * i <= n; ++i) {
			if(n % i == 0) {
				result = false;
				break;
			}
		}
		return result;
	}

	public static long gcd(long a, long b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	public static int gcd(int a, int b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	public static int[][] transpose(int[][] mat) {
		int r = mat.length;
		int c = mat[0].length;
		int[][] result = new int[c][r];
		for (int i = 0; i < c; ++i)
			for (int j = 0; j < r; ++j)
				result[i][j] = mat[j][i];
		return result;
	}

	public static String repeatString(String s, long count) {
		StringBuilder sb = new StringBuilder();
		for (long i = 0; i < count; ++i) {
			sb.append(s);
		}
		return sb.toString();
	}
}

class Treap<K extends Comparable<? super K>, V> {
	
	Treap() {
		nullNode = new TreapNode<K, V>();
		nullNode.left = nullNode.right = nullNode;
		nullNode.priority = Integer.MAX_VALUE;
		rootNode = nullNode;
	}
	
	public V put(K key, V value) {
		PutResult<K, V> putResult = putHelp(rootNode, key, value);
		rootNode = putResult.newNode;
		return putResult.originalValue;
	}
	
	public V get(K key) {
		TreapNode<K, V> currentNode = rootNode;
		while(currentNode != nullNode && currentNode.key.compareTo(key) != 0) {
			if(key.compareTo(currentNode.key) < 0) {
				currentNode = currentNode.left;
			} else {
				currentNode = currentNode.right;
			}
		}
		
		if(currentNode == nullNode) {
			return null;
		} else {
			return currentNode.value;
		}
	}
	
	public V remove(K key) {
		V result = get(key);
		if(result != null) {
			rootNode = removeHelp(rootNode, key);
		}
		return result;
	}
	
	public K select(int rank) {
		if(rank >= size() || rank < 0) {
			return null;
		}
		TreapNode<K, V> currentNode = rootNode;
		while(rank != currentNode.left.size) {
			if(rank < currentNode.left.size) {
				currentNode = currentNode.left;
			} else {
				rank -= currentNode.left.size + 1;
				currentNode = currentNode.right;
			}
		}
		
		return currentNode.key;
	}
	
	public int rank(K key) {
		if(rootNode == nullNode) {
			return -1;
		}
		int result = rootNode.left.size;
		TreapNode<K, V> currentNode = rootNode;
		while(currentNode != nullNode && currentNode.key.compareTo(key) != 0) {
			if(key.compareTo(currentNode.key) < 0) {
				result -= currentNode.left.right.size + 1;
				currentNode = currentNode.left;
			} else {
				result += currentNode.right.left.size + 1;
				currentNode = currentNode.right;
			}
		}
		
		if(currentNode == nullNode) {
			return -1;
		} else {
			return result;
		}
	}
	
	public void clear() {
		rootNode = nullNode;
	}
	
	public int size() {
		return rootNode.size;
	}
	
	private static class TreapNode<K, V> {
		public K key;
		public V value;
		public int size;
		public int priority;
		TreapNode<K, V> left, right;
	}
	
	private static class PutResult<K, V> {
		public TreapNode<K, V> newNode;
		public V originalValue;
	}
	
	private PutResult<K, V> putHelp(TreapNode<K, V> node, K key, V value) {
		if(node == nullNode) {
			PutResult<K, V> result = new PutResult<K, V>();
			result.newNode = new TreapNode<K, V>();
			result.newNode.key = key;
			result.newNode.value = value;
			result.newNode.size = 1;
			result.newNode.priority = randomPriority.nextInt(Integer.MAX_VALUE);
			result.newNode.left = result.newNode.right = nullNode;
			return result;
		} else if(key.compareTo(node.key) == 0) {
			PutResult<K, V> result = new PutResult<K, V>();
			result.originalValue = node.value;
			node.value = value;
			result.newNode = node;
			return result;
		} else if(key.compareTo(node.key) < 0) {
			PutResult<K, V> result = putHelp(node.left, key, value);
			node.left = result.newNode;
			if(result.originalValue == null) {
				++node.size;
				if(node.left.priority < node.priority) {
					node = rightRotate(node);
				}
			}
			result.newNode = node;
			return result;
		} else {
			PutResult<K, V> result = putHelp(node.right, key, value);
			node.right = result.newNode;
			if(result.originalValue == null) {
				++node.size;
				if(node.right.priority < node.priority) {
					node = leftRotate(node);
				}
			}
			result.newNode = node;
			return result;
		}
	}
	
	private TreapNode<K, V> removeHelp(TreapNode<K, V> node, K key) {
		if(key.compareTo(node.key) == 0) {
			node = removeHelp2(node);
		} else if(key.compareTo(node.key) < 0) {
			--node.size;
			node.left = removeHelp(node.left, key);
		} else {
			--node.size;
			node.right = removeHelp(node.right, key);
		}
		return node;
	}
	
	private TreapNode<K, V> removeHelp2(TreapNode<K, V> node) {
		if(node.left == nullNode && node.right == nullNode) {
			return nullNode;
		}
		
		if(node.left.priority < node.right.priority) {
			node = rightRotate(node);
			--node.size;
			node.right = removeHelp2(node.right);
		} else {
			node = leftRotate(node);
			--node.size;
			node.left = removeHelp2(node.left);
		}
		return node;
	}
	
	private TreapNode<K, V> leftRotate(TreapNode<K, V> node) {
		TreapNode<K, V> result = node.right;
		node.right = result.left;
		result.left = node;
		result.size = node.size;
		node.size -= 1 + result.right.size;
		return result;
	}
	
	private TreapNode<K, V> rightRotate(TreapNode<K, V> node) {
		TreapNode<K, V> result = node.left;
		node.left = result.right;
		result.right = node;
		result.size = node.size;
		node.size -= 1 + result.left.size;
		return result;
	}
	
	private TreapNode<K, V> nullNode;
	private TreapNode<K, V> rootNode;
	private Random randomPriority = new Random();
}