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

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

l = A("l")
h = B("h")
m = B("m")
e = B("e")
j = A("j")
d = B("d")
c = A("c")
a = A("a")
i = B("i")
k = A("k")

l.o = d
l.w = c
h.q = e
m.q = h
e.q = h
j.o = e
j.w = a
d.q = m
c.o = i
c.w = a
a.o = m
a.w = l
i.q = h
k.o = e
k.w = j
assert h.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: A = None
        self.txt = txt

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

l = A("l")
h = B("h")
m = B("m")
e = B("e")
j = A("j")
d = B("d")
c = A("c")
a = A("a")
i = B("i")
k = A("k")

l.o = d
l.w = c
h.q = e
m.q = h
e.q = h
j.o = e
j.w = a
d.q = m
c.o = i
c.w = a
a.o = m
a.w = l
i.q = h
k.o = e
k.w = j
assert h.q.q.q.q.q.txt == "e"