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

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

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

c = A("c")
k = B("k")
f = C("f")
n = C("n")
j = A("j")
g = B("g")

c.y = f
c.q = n
c.p = k
k.t = f
f.z = j
n.z = j
j.y = n
j.q = n
j.p = g
g.t = f
assert j.p.t.z.q.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: C = None
        self.p: B = None
        self.txt = txt

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

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

c = A("c")
k = B("k")
f = C("f")
n = C("n")
j = A("j")
g = B("g")

c.y = f
c.q = n
c.p = k
k.t = f
f.z = j
n.z = j
j.y = n
j.q = n
j.p = g
g.t = f
assert j.p.t.z.q.z.p.txt == "g"