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

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

i = A("i")
n = B("n")
m = A("m")
c = B("c")
e = B("e")
f = B("f")
l = B("l")
h = A("h")

i.w = n
i.o = h
n.u = c
m.w = f
m.o = h
c.u = e
e.u = n
f.u = n
l.u = f
h.w = f
h.o = i
assert c.u.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: A = None
        self.txt = txt

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

i = A("i")
n = B("n")
m = A("m")
c = B("c")
e = B("e")
f = B("f")
l = B("l")
h = A("h")

i.w = n
i.o = h
n.u = c
m.w = f
m.o = h
c.u = e
e.u = n
f.u = n
l.u = f
h.w = f
h.o = i
assert c.u.u.u.u.u.u.u.u.txt == "n"