class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: B = None
        self.txt = txt

i = A("i")
a = B("a")
k = B("k")
c = B("c")
h = B("h")
b = B("b")
m = A("m")
n = A("n")

i.t = b
a.r = m
a.y = c
k.r = m
k.y = h
c.r = m
c.y = h
h.r = i
h.y = c
b.r = i
b.y = c
m.t = k
n.t = a
assert a.y.y.y.r.t.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: B = None
        self.txt = txt

i = A("i")
a = B("a")
k = B("k")
c = B("c")
h = B("h")
b = B("b")
m = A("m")
n = A("n")

i.t = b
a.r = m
a.y = c
k.r = m
k.y = h
c.r = m
c.y = h
h.r = i
h.y = c
b.r = i
b.y = c
m.t = k
n.t = a
assert a.y.y.y.r.t.y.r.txt == "i"