input: Write a Python function to determine the minimum travel cost within an undirected weighted graph with 'n' vertices (labeled from 0 to n-1) based on given edge details and query pairs. The 'edges' array specifies the connections and their weights, and the 'query' array requires computing the minimal Walk cost from start to end vertices where the Walk's cost is defined as the bitwise AND of all edge weights in the path. If no valid Walk exists, return -1.
  
  
  from typing import List
  
  def minimum_travel_expense(n: int, edges: List[List[int]], query: List[List[int]]) -> List[int]:
      """
      This function calculates the least cost to traverse an undirected graph with given number of vertices and edges.
      
      Parameters:
      - n: Number of vertices in the graph.
      - edges: A 2D list where each element [u, v, w] represents an edge between vertices u and v with weight w.
      - query: A 2D list where each element [s, t] requires finding the minimal cost for a walk from vertex s to vertex t.
  
      Returns:
      - A list of minimal costs for each pair in the query. If a walk does not exist, the result for that query should be -1.
      """
  
output: 
  def minimum_travel_expense(n: int, edges: List[List[int]], query: List[List[int]]) -> List[int]:
      from collections import defaultdict, deque
      
      def bfs(start, end, weight):
          visited = [False] * n
          queue = deque([start])
          visited[start] = True
          while queue:
              node = queue.popleft()
              if node == end:
                  return True
              for neighbor in graph[node]:
                  if not visited[neighbor] and edge_weights[(node, neighbor)] & weight == weight:
                      visited[neighbor] = True
                      queue.append(neighbor)
          return False
      
      graph = defaultdict(list)
      edge_weights = {}
      
      for u, v, w in edges:
          graph[u].append(v)
          graph[v].append(u)
          edge_weights[(u, v)] = w
          edge_weights[(v, u)] = w
      
      results = []
      for s, t in query:
          min_weight = float('inf')
          for u, v, w in edges:
              if bfs(s, t, w):
                  min_weight = min(min_weight, w)
          results.append(min_weight if min_weight != float('inf') else -1)
      
      return results
  