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

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

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

j = A("j")
c = B("c")
n = C("n")
d = B("d")
f = C("f")
a = B("a")
e = C("e")
m = A("m")

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

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

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

j = A("j")
c = B("c")
n = C("n")
d = B("d")
f = C("f")
a = B("a")
e = C("e")
m = A("m")

j.r = d
j.w = d
c.z = j
c.t = j
n.t = e
d.z = j
d.t = m
f.t = e
a.z = j
a.t = j
e.t = n
m.r = c
m.w = d
assert e.t.t.t.txt == "n"