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

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

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

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

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

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

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

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

n.o = d
n.t = c
a.r = n
d.z = e
h.r = n
f.r = n
j.o = d
j.t = f
c.r = n
e.r = j
assert d.z.r.t.r.o.z.txt == "e"