You are given two jugs with capacities x and y liters and an unlimited water source. You may perform these operations: fill a jug, empty a jug, or pour from one jug to the other until one becomes full or the other becomes empty. Determine whether it is possible to measure exactly z liters in either jug. If it is possible, return true and optionally output one valid sequence of operations; otherwise return false. Describe and analyze both a graph-search approach (e.g., BFS/DFS over states) and a number-theoretic approach (using properties of gcd), including edge cases such as z == 0, z > x + y, and when x or y is 0. Implement canMeasure(x, y, z) and provide time and space complexity.