broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    pc=x['pc']; con=x['construction']
    if x['station_miles']>=5: pc='10'
    elif x['hydrant_feet']>1000 and pc not in ('8B','9','10'): pc='9'
    key=pc+'-'+con
    if key in x['matrix']: f=Fraction(x['matrix'][key],1000)
    elif con=='masonry' and pc+'-frame' in x['matrix']: f=Fraction(x['matrix'][pc+'-frame'],1000)*Fraction(95,100)
    else: return 'unrated '+key
    return math.floor(x['base']*f+Fraction(1,2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['protected frame', {'base': 120317, 'pc': '2', 'construction': 'frame', 'station_miles': 2, 'hydrant_feet': 300, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 103593], ['station exactly five miles', {'base': 247853, 'pc': '4', 'construction': 'masonry', 'station_miles': 5, 'hydrant_feet': 400, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 229264], ['beyond five miles', {'base': 235309, 'pc': '3', 'construction': 'frame', 'station_miles': 5.5, 'hydrant_feet': 200, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 329668], ['distant hydrant downgrades', {'base': 90594, 'pc': '5', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1030, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 121487], ['hydrant exactly 1000 feet', {'base': 178365, 'pc': '6', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1000, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 196380], ['split class keeps 8B', {'base': 197429, 'pc': '8B', 'construction': 'frame', 'station_miles': 4, 'hydrant_feet': 1500, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 252907], ['masonry downgraded uses frame fallback', {'base': 201148, 'pc': '7', 'construction': 'masonry', 'station_miles': 2, 'hydrant_feet': 1400, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 256252], ['masonry class 10 fallback', {'base': 217127, 'pc': '3', 'construction': 'masonry', 'station_miles': 7, 'hydrant_feet': 100, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 288985], ['fire resistive unrated', {'base': 212313, 'pc': '9', 'construction': 'fire-resistive', 'station_miles': 1, 'hydrant_feet': 100, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 'unrated 9-fire-resistive'], ['masonry protected', {'base': 186678, 'pc': '8', 'construction': 'masonry', 'station_miles': 1, 'hydrant_feet': 200, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 213746]], [['protected frame', {'base': 184759, 'pc': '2', 'construction': 'frame', 'station_miles': 2, 'hydrant_feet': 300, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 159262], ['station exactly five miles', {'base': 141915, 'pc': '4', 'construction': 'masonry', 'station_miles': 5, 'hydrant_feet': 400, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 131271], ['beyond five miles', {'base': 198782, 'pc': '3', 'construction': 'frame', 'station_miles': 5.5, 'hydrant_feet': 200, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 278692], ['distant hydrant downgrades', {'base': 97374, 'pc': '5', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1030, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 130676], ['hydrant exactly 1000 feet', {'base': 119429, 'pc': '6', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1000, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 131611], ['split class keeps 8B', {'base': 152686, 'pc': '8B', 'construction': 'frame', 'station_miles': 4, 'hydrant_feet': 1500, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 195743], ['masonry downgraded uses frame fallback', {'base': 105761, 'pc': '7', 'construction': 'masonry', 'station_miles': 2, 'hydrant_feet': 1400, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 134835], ['masonry class 10 fallback', {'base': 112632, 'pc': '3', 'construction': 'masonry', 'station_miles': 7, 'hydrant_feet': 100, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 150015], ['fire resistive unrated', {'base': 169686, 'pc': '9', 'construction': 'fire-resistive', 'station_miles': 1, 'hydrant_feet': 100, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 'unrated 9-fire-resistive'], ['masonry protected', {'base': 202626, 'pc': '8', 'construction': 'masonry', 'station_miles': 1, 'hydrant_feet': 200, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 232007]], [['protected frame', {'base': 204115, 'pc': '4', 'construction': 'frame', 'station_miles': 2, 'hydrant_feet': 300, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 200645], ['station exactly five miles', {'base': 156901, 'pc': '4', 'construction': 'frame', 'station_miles': 5, 'hydrant_feet': 400, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 154234], ['beyond five miles', {'base': 115311, 'pc': '3', 'construction': 'frame', 'station_miles': 5.5, 'hydrant_feet': 200, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 161781], ['distant hydrant downgrades', {'base': 150626, 'pc': '5', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1030, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 202291], ['hydrant exactly 1000 feet', {'base': 122970, 'pc': '6', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1000, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 135636], ['split class keeps 8B', {'base': 163526, 'pc': '8B', 'construction': 'frame', 'station_miles': 4, 'hydrant_feet': 1500, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 209804], ['masonry downgraded uses frame fallback', {'base': 154344, 'pc': '7', 'construction': 'masonry', 'station_miles': 2, 'hydrant_feet': 1400, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 196920], ['masonry class 10 fallback', {'base': 127756, 'pc': '3', 'construction': 'masonry', 'station_miles': 7, 'hydrant_feet': 100, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 170280], ['fire resistive unrated', {'base': 229613, 'pc': '9', 'construction': 'fire-resistive', 'station_miles': 1, 'hydrant_feet': 100, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 'unrated 9-fire-resistive'], ['masonry protected', {'base': 92691, 'pc': '8', 'construction': 'masonry', 'station_miles': 1, 'hydrant_feet': 200, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 106131]], [['protected frame', {'base': 247005, 'pc': '2', 'construction': 'frame', 'station_miles': 2, 'hydrant_feet': 300, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 213412], ['station exactly five miles', {'base': 224534, 'pc': '4', 'construction': 'masonry', 'station_miles': 5, 'hydrant_feet': 400, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 207694], ['beyond five miles', {'base': 241571, 'pc': '3', 'construction': 'frame', 'station_miles': 5.5, 'hydrant_feet': 200, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 339166], ['distant hydrant downgrades', {'base': 161859, 'pc': '5', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1030, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 217538], ['hydrant exactly 1000 feet', {'base': 142348, 'pc': '6', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1000, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 157152], ['split class keeps 8B', {'base': 76654, 'pc': '8B', 'construction': 'frame', 'station_miles': 4, 'hydrant_feet': 1500, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 98424], ['masonry downgraded uses frame fallback', {'base': 150835, 'pc': '7', 'construction': 'masonry', 'station_miles': 2, 'hydrant_feet': 1400, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 192586], ['masonry class 10 fallback', {'base': 175432, 'pc': '3', 'construction': 'masonry', 'station_miles': 7, 'hydrant_feet': 100, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 233991], ['fire resistive unrated', {'base': 103540, 'pc': '9', 'construction': 'fire-resistive', 'station_miles': 1, 'hydrant_feet': 100, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 'unrated 9-fire-resistive'], ['masonry protected', {'base': 83396, 'pc': '8', 'construction': 'masonry', 'station_miles': 1, 'hydrant_feet': 200, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 95488]], [['protected frame', {'base': 182973, 'pc': '2', 'construction': 'frame', 'station_miles': 2, 'hydrant_feet': 300, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 158272], ['station exactly five miles', {'base': 226119, 'pc': '4', 'construction': 'frame', 'station_miles': 5, 'hydrant_feet': 400, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 222727], ['beyond five miles', {'base': 98376, 'pc': '3', 'construction': 'frame', 'station_miles': 5.5, 'hydrant_feet': 200, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 138218], ['distant hydrant downgrades', {'base': 168912, 'pc': '5', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1030, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 227187], ['hydrant exactly 1000 feet', {'base': 213720, 'pc': '6', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1000, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 236161], ['split class keeps 8B', {'base': 61162, 'pc': '8B', 'construction': 'frame', 'station_miles': 4, 'hydrant_feet': 1500, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 78593], ['masonry downgraded uses frame fallback', {'base': 109402, 'pc': '7', 'construction': 'masonry', 'station_miles': 2, 'hydrant_feet': 1400, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 139788], ['masonry class 10 fallback', {'base': 131356, 'pc': '3', 'construction': 'masonry', 'station_miles': 7, 'hydrant_feet': 100, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 175327], ['fire resistive unrated', {'base': 230152, 'pc': '9', 'construction': 'fire-resistive', 'station_miles': 1, 'hydrant_feet': 100, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 'unrated 9-fire-resistive'], ['masonry protected', {'base': 90689, 'pc': '8', 'construction': 'masonry', 'station_miles': 1, 'hydrant_feet': 200, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 103839]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    pc=x['pc']; con=x['construction']
    if x['station_miles']>5 and x['hydrant_feet']>1000: pc='10'
    elif x['hydrant_feet']>1000 and pc not in ('8B','9','10'): pc='9'
    key=pc+'-'+con
    if key in x['matrix']: f=Fraction(x['matrix'][key],1000)
    elif con=='masonry' and pc+'-frame' in x['matrix']: f=Fraction(x['matrix'][pc+'-frame'],1000)*Fraction(95,100)
    else: return 'unrated '+key
    return math.floor(x['base']*f+Fraction(1,2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['protected frame', {'base': 120317, 'pc': '2', 'construction': 'frame', 'station_miles': 2, 'hydrant_feet': 300, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 103593], ['station exactly five miles', {'base': 247853, 'pc': '4', 'construction': 'masonry', 'station_miles': 5, 'hydrant_feet': 400, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 229264], ['beyond five miles', {'base': 235309, 'pc': '3', 'construction': 'frame', 'station_miles': 5.5, 'hydrant_feet': 200, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 329668], ['distant hydrant downgrades', {'base': 90594, 'pc': '5', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1030, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 121487], ['hydrant exactly 1000 feet', {'base': 178365, 'pc': '6', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1000, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 196380], ['split class keeps 8B', {'base': 197429, 'pc': '8B', 'construction': 'frame', 'station_miles': 4, 'hydrant_feet': 1500, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 252907], ['masonry downgraded uses frame fallback', {'base': 201148, 'pc': '7', 'construction': 'masonry', 'station_miles': 2, 'hydrant_feet': 1400, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 256252], ['masonry class 10 fallback', {'base': 217127, 'pc': '3', 'construction': 'masonry', 'station_miles': 7, 'hydrant_feet': 100, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 288985], ['fire resistive unrated', {'base': 212313, 'pc': '9', 'construction': 'fire-resistive', 'station_miles': 1, 'hydrant_feet': 100, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 'unrated 9-fire-resistive'], ['masonry protected', {'base': 186678, 'pc': '8', 'construction': 'masonry', 'station_miles': 1, 'hydrant_feet': 200, 'matrix': {'1-frame': 801, '1-masonry': 760, '2-frame': 861, '2-masonry': 815, '3-frame': 921, '3-masonry': 870, '4-frame': 981, '4-masonry': 925, '5-frame': 1041, '5-masonry': 980, '6-frame': 1101, '6-masonry': 1035, '7-frame': 1161, '7-masonry': 1090, '8-frame': 1221, '8-masonry': 1145, '8B-frame': 1281, '8B-masonry': 1200, '9-frame': 1341, '10-frame': 1401}}, 213746]], [['protected frame', {'base': 184759, 'pc': '2', 'construction': 'frame', 'station_miles': 2, 'hydrant_feet': 300, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 159262], ['station exactly five miles', {'base': 141915, 'pc': '4', 'construction': 'masonry', 'station_miles': 5, 'hydrant_feet': 400, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 131271], ['beyond five miles', {'base': 198782, 'pc': '3', 'construction': 'frame', 'station_miles': 5.5, 'hydrant_feet': 200, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 278692], ['distant hydrant downgrades', {'base': 97374, 'pc': '5', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1030, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 130676], ['hydrant exactly 1000 feet', {'base': 119429, 'pc': '6', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1000, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 131611], ['split class keeps 8B', {'base': 152686, 'pc': '8B', 'construction': 'frame', 'station_miles': 4, 'hydrant_feet': 1500, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 195743], ['masonry downgraded uses frame fallback', {'base': 105761, 'pc': '7', 'construction': 'masonry', 'station_miles': 2, 'hydrant_feet': 1400, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 134835], ['masonry class 10 fallback', {'base': 112632, 'pc': '3', 'construction': 'masonry', 'station_miles': 7, 'hydrant_feet': 100, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 150015], ['fire resistive unrated', {'base': 169686, 'pc': '9', 'construction': 'fire-resistive', 'station_miles': 1, 'hydrant_feet': 100, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 'unrated 9-fire-resistive'], ['masonry protected', {'base': 202626, 'pc': '8', 'construction': 'masonry', 'station_miles': 1, 'hydrant_feet': 200, 'matrix': {'1-frame': 802, '1-masonry': 760, '2-frame': 862, '2-masonry': 815, '3-frame': 922, '3-masonry': 870, '4-frame': 982, '4-masonry': 925, '5-frame': 1042, '5-masonry': 980, '6-frame': 1102, '6-masonry': 1035, '7-frame': 1162, '7-masonry': 1090, '8-frame': 1222, '8-masonry': 1145, '8B-frame': 1282, '8B-masonry': 1200, '9-frame': 1342, '10-frame': 1402}}, 232007]], [['protected frame', {'base': 204115, 'pc': '4', 'construction': 'frame', 'station_miles': 2, 'hydrant_feet': 300, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 200645], ['station exactly five miles', {'base': 156901, 'pc': '4', 'construction': 'frame', 'station_miles': 5, 'hydrant_feet': 400, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 154234], ['beyond five miles', {'base': 115311, 'pc': '3', 'construction': 'frame', 'station_miles': 5.5, 'hydrant_feet': 200, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 161781], ['distant hydrant downgrades', {'base': 150626, 'pc': '5', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1030, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 202291], ['hydrant exactly 1000 feet', {'base': 122970, 'pc': '6', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1000, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 135636], ['split class keeps 8B', {'base': 163526, 'pc': '8B', 'construction': 'frame', 'station_miles': 4, 'hydrant_feet': 1500, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 209804], ['masonry downgraded uses frame fallback', {'base': 154344, 'pc': '7', 'construction': 'masonry', 'station_miles': 2, 'hydrant_feet': 1400, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 196920], ['masonry class 10 fallback', {'base': 127756, 'pc': '3', 'construction': 'masonry', 'station_miles': 7, 'hydrant_feet': 100, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 170280], ['fire resistive unrated', {'base': 229613, 'pc': '9', 'construction': 'fire-resistive', 'station_miles': 1, 'hydrant_feet': 100, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 'unrated 9-fire-resistive'], ['masonry protected', {'base': 92691, 'pc': '8', 'construction': 'masonry', 'station_miles': 1, 'hydrant_feet': 200, 'matrix': {'1-frame': 803, '1-masonry': 760, '2-frame': 863, '2-masonry': 815, '3-frame': 923, '3-masonry': 870, '4-frame': 983, '4-masonry': 925, '5-frame': 1043, '5-masonry': 980, '6-frame': 1103, '6-masonry': 1035, '7-frame': 1163, '7-masonry': 1090, '8-frame': 1223, '8-masonry': 1145, '8B-frame': 1283, '8B-masonry': 1200, '9-frame': 1343, '10-frame': 1403}}, 106131]], [['protected frame', {'base': 247005, 'pc': '2', 'construction': 'frame', 'station_miles': 2, 'hydrant_feet': 300, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 213412], ['station exactly five miles', {'base': 224534, 'pc': '4', 'construction': 'masonry', 'station_miles': 5, 'hydrant_feet': 400, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 207694], ['beyond five miles', {'base': 241571, 'pc': '3', 'construction': 'frame', 'station_miles': 5.5, 'hydrant_feet': 200, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 339166], ['distant hydrant downgrades', {'base': 161859, 'pc': '5', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1030, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 217538], ['hydrant exactly 1000 feet', {'base': 142348, 'pc': '6', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1000, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 157152], ['split class keeps 8B', {'base': 76654, 'pc': '8B', 'construction': 'frame', 'station_miles': 4, 'hydrant_feet': 1500, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 98424], ['masonry downgraded uses frame fallback', {'base': 150835, 'pc': '7', 'construction': 'masonry', 'station_miles': 2, 'hydrant_feet': 1400, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 192586], ['masonry class 10 fallback', {'base': 175432, 'pc': '3', 'construction': 'masonry', 'station_miles': 7, 'hydrant_feet': 100, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 233991], ['fire resistive unrated', {'base': 103540, 'pc': '9', 'construction': 'fire-resistive', 'station_miles': 1, 'hydrant_feet': 100, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 'unrated 9-fire-resistive'], ['masonry protected', {'base': 83396, 'pc': '8', 'construction': 'masonry', 'station_miles': 1, 'hydrant_feet': 200, 'matrix': {'1-frame': 804, '1-masonry': 760, '2-frame': 864, '2-masonry': 815, '3-frame': 924, '3-masonry': 870, '4-frame': 984, '4-masonry': 925, '5-frame': 1044, '5-masonry': 980, '6-frame': 1104, '6-masonry': 1035, '7-frame': 1164, '7-masonry': 1090, '8-frame': 1224, '8-masonry': 1145, '8B-frame': 1284, '8B-masonry': 1200, '9-frame': 1344, '10-frame': 1404}}, 95488]], [['protected frame', {'base': 182973, 'pc': '2', 'construction': 'frame', 'station_miles': 2, 'hydrant_feet': 300, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 158272], ['station exactly five miles', {'base': 226119, 'pc': '4', 'construction': 'frame', 'station_miles': 5, 'hydrant_feet': 400, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 222727], ['beyond five miles', {'base': 98376, 'pc': '3', 'construction': 'frame', 'station_miles': 5.5, 'hydrant_feet': 200, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 138218], ['distant hydrant downgrades', {'base': 168912, 'pc': '5', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1030, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 227187], ['hydrant exactly 1000 feet', {'base': 213720, 'pc': '6', 'construction': 'frame', 'station_miles': 3, 'hydrant_feet': 1000, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 236161], ['split class keeps 8B', {'base': 61162, 'pc': '8B', 'construction': 'frame', 'station_miles': 4, 'hydrant_feet': 1500, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 78593], ['masonry downgraded uses frame fallback', {'base': 109402, 'pc': '7', 'construction': 'masonry', 'station_miles': 2, 'hydrant_feet': 1400, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 139788], ['masonry class 10 fallback', {'base': 131356, 'pc': '3', 'construction': 'masonry', 'station_miles': 7, 'hydrant_feet': 100, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 175327], ['fire resistive unrated', {'base': 230152, 'pc': '9', 'construction': 'fire-resistive', 'station_miles': 1, 'hydrant_feet': 100, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 'unrated 9-fire-resistive'], ['masonry protected', {'base': 90689, 'pc': '8', 'construction': 'masonry', 'station_miles': 1, 'hydrant_feet': 200, 'matrix': {'1-frame': 805, '1-masonry': 760, '2-frame': 865, '2-masonry': 815, '3-frame': 925, '3-masonry': 870, '4-frame': 985, '4-masonry': 925, '5-frame': 1045, '5-masonry': 980, '6-frame': 1105, '6-masonry': 1035, '7-frame': 1165, '7-masonry': 1090, '8-frame': 1225, '8-masonry': 1145, '8B-frame': 1285, '8B-masonry': 1200, '9-frame': 1345, '10-frame': 1405}}, 103839]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Homes exactly five road miles from a station are rated class 10.

Input base, pc ('1'..'10' or split class '8B'), construction, station_miles, hydrant_feet, matrix {'pc-construction': factor*1000}. More than 5 miles from a station -> class 10; else hydrant over 1000 ft downgrades classes other than 8B/9/10 to 9. Missing masonry factors fall back to 95% of the frame factor; any other missing cell -> 'unrated <key>'.

split: open-access