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

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

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

h = A("h")
d = B("d")
m = C("m")
i = C("i")
l = B("l")
g = A("g")

h.u = i
h.o = d
h.w = g
d.v = l
m.w = i
i.w = m
l.v = d
g.u = i
g.o = l
g.w = h
assert h.u.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.o: B = None
        self.w: A = None
        self.txt = txt

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

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

h = A("h")
d = B("d")
m = C("m")
i = C("i")
l = B("l")
g = A("g")

h.u = i
h.o = d
h.w = g
d.v = l
m.w = i
i.w = m
l.v = d
g.u = i
g.o = l
g.w = h
assert h.u.w.w.w.w.w.txt == "m"