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

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

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

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

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

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

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

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

d.z = f
d.t = j
k.x = e
k.z = j
k.q = f
f.v = d
f.x = d
e.v = d
e.x = j
j.z = f
j.t = d
assert f.x.t.z.txt == "f"