def main(): A = int(input()) if A == 0: print(2, 0) return if A == 1: print(1, 0) return # Factor A into factors of 3 and 2, then remainder factors = [] current = A while current > 1: if current % 3 == 0: factors.append(3) current = current // 3 elif current % 2 == 0: factors.append(2) current = current // 2 else: # Check for any divisor from 2 to sqrt(current) found = False for i in range(2, int(current**0.5) + 1): if current % i == 0: factors.append(i) current = current // i found = True break if not found: factors.append(current) current = 1 sum_factors = sum(factors) if sum_factors > 126: # Handle cases where sum exceeds 126 by further factorization (not fully implemented) # This part is a placeholder and may not work for all cases pass # Build the graph n = 1 + sum(factors) + 1 edges = [] prev_layer = [1] current_node = 2 for i in range(len(factors)): layer_size = factors[i] current_layer = list(range(current_node, current_node + layer_size)) current_node += layer_size # Connect previous layer to current layer for u in prev_layer: for v in current_layer: edges.append((u, v)) prev_layer = current_layer # Connect last layer to end node end_node = current_node for u in prev_layer: edges.append((u, end_node)) # Check if end_node exceeds 128 if end_node > 128: # This part is a placeholder and may not work for all cases # Alternative approach needed for large primes, not implemented here pass # Output print(end_node, len(edges)) for a, b in edges: print(a, b) if __name__ == "__main__": main()