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

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

j = A("j")
f = B("f")
k = B("k")
l = A("l")
b = A("b")
c = A("c")
h = B("h")
e = A("e")
a = A("a")

j.s = l
j.o = a
f.q = h
k.q = f
l.s = j
l.o = e
b.s = l
b.o = a
c.s = l
c.o = a
h.q = f
e.s = c
e.o = j
a.s = e
a.o = b
assert h.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.o: A = None
        self.txt = txt

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

j = A("j")
f = B("f")
k = B("k")
l = A("l")
b = A("b")
c = A("c")
h = B("h")
e = A("e")
a = A("a")

j.s = l
j.o = a
f.q = h
k.q = f
l.s = j
l.o = e
b.s = l
b.o = a
c.s = l
c.o = a
h.q = f
e.s = c
e.o = j
a.s = e
a.o = b
assert h.q.q.q.q.txt == "h"