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

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

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

g = A("g")
d = B("d")
j = C("j")
i = A("i")
k = B("k")
l = A("l")

g.p = j
g.o = j
g.u = l
d.p = j
d.q = j
j.z = k
i.p = j
i.o = j
i.u = l
k.p = j
k.q = j
l.p = j
l.o = j
l.u = i
assert g.o.z.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.o: C = None
        self.u: A = None
        self.txt = txt

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

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

g = A("g")
d = B("d")
j = C("j")
i = A("i")
k = B("k")
l = A("l")

g.p = j
g.o = j
g.u = l
d.p = j
d.q = j
j.z = k
i.p = j
i.o = j
i.u = l
k.p = j
k.q = j
l.p = j
l.o = j
l.u = i
assert g.o.z.q.z.txt == "k"