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

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

k = A("k")
m = B("m")
n = A("n")
l = A("l")
c = A("c")
j = B("j")
i = B("i")
b = A("b")
e = B("e")

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

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

k = A("k")
m = B("m")
n = A("n")
l = A("l")
c = A("c")
j = B("j")
i = B("i")
b = A("b")
e = B("e")

k.t = e
k.x = e
m.z = l
m.r = j
n.t = j
n.x = e
l.t = m
l.x = i
c.t = j
c.x = j
j.z = n
j.r = e
i.z = l
i.r = e
b.t = m
b.x = m
e.z = n
e.r = i
assert j.r.r.z.t.r.r.txt == "e"