import re def list_of_points_in_space(d: {}) -> []: li = [] for w in range(int(d["w"])): for h in range(int(d["h"])): t = (int(d["ls"]) + w, int(d["ts"]) + h) li.append(t) return li def list_of_points_in_space_dict(d: {}) -> {}: # Zwraca listę punktów w przestrzeni zajmowaną przez określny claim # lista tupli, tzn. [(0,0), (0,1)] itd. result_dict = {} for d2 in d.values(): for t in list_of_points_in_space(d2): result_dict[t] = result_dict.get(t, 0) + 1 return result_dict if __name__ == "__main__": # Pobieranie danych i zaczytywanie do dict d = {} ids = [] inpt = input() while inpt: #id @ left_shift,top_shift: WidthxHeight dupa_re = re.compile(r"\#(\d{1,4}) \@ (\d{1,3})\,(\d{1,3})\: (\d{1,2})x(\d{1,2})") m = dupa_re.search(inpt) d_temp = {"ls": m.group(2), "ts": m.group(3), "w": m.group(4), "h": m.group(5)} # d[m.group(1)] = d_temp # stary sposób li = list_of_points_in_space(d_temp) for t in li: if t in d: d[t].append(int(m.group(1))) else: d[t] = [int(m.group(1))] ids.append(int(m.group(1))) inpt = input() # Szukanie takiego ID, który nie występuje w parze z innym ID # w żadnym kluczu (tupli) bad_ids, good_ids = [], [] for v in d.values(): if len(v) > 1: bad_ids += v else: good_ids += v for x in set(good_ids): if x not in bad_ids: print(x) break