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

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

b = A("b")
j = B("j")
a = B("a")
g = B("g")
c = B("c")
d = B("d")
e = B("e")
m = B("m")
i = B("i")
n = B("n")

b.z = j
b.r = n
j.t = e
a.t = n
g.t = d
c.t = a
d.t = c
e.t = d
m.t = j
i.t = d
n.t = j
assert b.z.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.txt = txt

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

b = A("b")
j = B("j")
a = B("a")
g = B("g")
c = B("c")
d = B("d")
e = B("e")
m = B("m")
i = B("i")
n = B("n")

b.z = j
b.r = n
j.t = e
a.t = n
g.t = d
c.t = a
d.t = c
e.t = d
m.t = j
i.t = d
n.t = j
assert b.z.t.t.t.t.t.t.txt == "j"