Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Monday, Dec 7.Claim the deal

An IP address is a formatted 32-bit unsigned integer where each group of 8 bits is printed as a decimal number and the dot character '.' splits the groups.

  • For example, the binary number 11000000 10101000 00000001 01111011 (spaces added for clarity) formatted as an IP address would be "192.168.1.123".

A CIDR block is a format used to denote a specific set of IP addresses. It is a string consisting of a base IP address, followed by a slash, followed by a prefix length k. The addresses it covers are all the IPs whose first k bits are the same as the base IP address.

  • For example, "192.168.1.0/24" is a CIDR block with a prefix length of 24. Any IP address whose binary representation matches 11000000 10101000 00000001 xxxxxxxx, where x can be either 0 or 1, is in the set covered by the CIDR block.

You are given a list of routing entries, where each entry is represented as a pair (prefix, nextHop):

  • prefix is a string containing an IPv4 address and subnet mask in CIDR notation (for example, "192.168.1.0/24").
  • nextHop is a string representing the destination URL for that prefix.

You are also given a list of queries, where each query is a string representing an IPv4 address (for example, "192.168.1.123").

Test Cases
Input
Output
Expected