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

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

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

h = A("h")
m = B("m")
n = C("n")
l = B("l")
k = C("k")
j = A("j")

h.y = n
m.w = n
n.s = m
n.o = h
l.w = n
k.s = m
k.o = h
j.y = k
assert l.w.s.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

h = A("h")
m = B("m")
n = C("n")
l = B("l")
k = C("k")
j = A("j")

h.y = n
m.w = n
n.s = m
n.o = h
l.w = n
k.s = m
k.o = h
j.y = k
assert l.w.s.w.s.w.txt == "n"