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

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

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

h = A("h")
d = B("d")
m = C("m")
j = A("j")

h.u = j
h.w = j
h.t = j
d.s = m
d.o = h
m.s = d
j.u = h
j.w = h
j.t = h
assert d.o.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: A = None
        self.t: A = None
        self.txt = txt

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

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

h = A("h")
d = B("d")
m = C("m")
j = A("j")

h.u = j
h.w = j
h.t = j
d.s = m
d.o = h
m.s = d
j.u = h
j.w = h
j.t = h
assert d.o.w.w.txt == "h"