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

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

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

g = A("g")
a = B("a")
f = C("f")
h = C("h")
m = C("m")
j = A("j")
b = B("b")
e = B("e")
c = C("c")
n = A("n")

g.z = m
a.z = h
a.q = e
a.p = g
f.t = j
h.t = j
m.t = g
j.z = c
b.z = h
b.q = e
b.p = n
e.z = h
e.q = b
e.p = g
c.t = n
n.z = m
assert e.q.p.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

g = A("g")
a = B("a")
f = C("f")
h = C("h")
m = C("m")
j = A("j")
b = B("b")
e = B("e")
c = C("c")
n = A("n")

g.z = m
a.z = h
a.q = e
a.p = g
f.t = j
h.t = j
m.t = g
j.z = c
b.z = h
b.q = e
b.p = n
e.z = h
e.q = b
e.p = g
c.t = n
n.z = m
assert e.q.p.z.t.txt == "g"