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

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

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

b = A("b")
d = B("d")
j = C("j")
k = A("k")
e = B("e")

b.p = j
b.z = j
d.v = j
d.o = k
d.q = e
j.x = e
j.z = d
j.s = k
k.p = j
k.z = j
e.v = j
e.o = k
e.q = d
assert d.q.q.q.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: C = None
        self.txt = txt

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

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

b = A("b")
d = B("d")
j = C("j")
k = A("k")
e = B("e")

b.p = j
b.z = j
d.v = j
d.o = k
d.q = e
j.x = e
j.z = d
j.s = k
k.p = j
k.z = j
e.v = j
e.o = k
e.q = d
assert d.q.q.q.v.z.txt == "d"