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

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

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

b = A("b")
m = B("m")
h = C("h")
g = A("g")
c = B("c")

b.t = m
m.v = b
h.w = g
h.y = c
g.t = c
c.v = g
assert m.v.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

b = A("b")
m = B("m")
h = C("h")
g = A("g")
c = B("c")

b.t = m
m.v = b
h.w = g
h.y = c
g.t = c
c.v = g
assert m.v.t.v.txt == "b"