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

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

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

m = A("m")
e = B("e")
d = C("d")
n = A("n")
g = B("g")
c = A("c")

m.u = g
m.w = e
m.t = e
e.x = d
e.t = n
d.s = c
n.u = e
n.w = e
n.t = g
g.x = d
g.t = m
c.u = e
c.t = e
c.w = g
assert g.x.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: B = None
        self.t: B = None
        self.txt = txt

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

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

m = A("m")
e = B("e")
d = C("d")
n = A("n")
g = B("g")
c = A("c")

m.u = g
m.w = e
m.t = e
e.x = d
e.t = n
d.s = c
n.u = e
n.w = e
n.t = g
g.x = d
g.t = m
c.u = e
c.t = e
c.w = g
assert g.x.s.w.txt == "g"