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

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

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

g = A("g")
k = B("k")
d = C("d")
a = B("a")

g.t = a
g.z = a
g.v = d
k.z = g
d.x = g
a.z = g
assert d.x.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: B = None
        self.v: C = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
d = C("d")
a = B("a")

g.t = a
g.z = a
g.v = d
k.z = g
d.x = g
a.z = g
assert d.x.v.x.txt == "g"