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

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

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

d = A("d")
j = B("j")
g = C("g")

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

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

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

d = A("d")
j = B("j")
g = C("g")

d.v = g
d.z = g
j.v = g
j.t = g
j.x = d
g.q = j
g.w = d
assert d.v.q.v.txt == "g"