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

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

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

a = A("a")
i = B("i")
m = C("m")
g = C("g")
b = B("b")

a.t = b
a.v = g
a.s = i
i.y = b
i.u = b
i.x = a
m.v = g
g.v = m
b.y = i
b.u = i
b.x = a
assert b.y.x.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: C = None
        self.s: B = None
        self.txt = txt

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

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

a = A("a")
i = B("i")
m = C("m")
g = C("g")
b = B("b")

a.t = b
a.v = g
a.s = i
i.y = b
i.u = b
i.x = a
m.v = g
g.v = m
b.y = i
b.u = i
b.x = a
assert b.y.x.s.y.txt == "b"