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

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

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

m = A("m")
f = B("f")
g = C("g")

m.x = g
m.t = g
f.y = g
f.w = m
g.v = m
assert m.x.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.t: C = None
        self.txt = txt

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

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

m = A("m")
f = B("f")
g = C("g")

m.x = g
m.t = g
f.y = g
f.w = m
g.v = m
assert m.x.v.t.txt == "g"