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

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

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

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

a.t = j
e.q = k
e.u = n
e.p = j
j.p = d
k.t = j
h.t = j
g.q = a
g.u = n
g.p = j
c.q = a
c.u = n
c.p = j
n.q = h
n.u = c
n.p = d
d.p = j
assert a.t.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

a.t = j
e.q = k
e.u = n
e.p = j
j.p = d
k.t = j
h.t = j
g.q = a
g.u = n
g.p = j
c.q = a
c.u = n
c.p = j
n.q = h
n.u = c
n.p = d
d.p = j
assert a.t.p.p.txt == "j"