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

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

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

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

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

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

l.u = m
l.q = a
m.o = l
c.o = l
d.o = l
g.o = e
j.o = l
e.u = m
e.q = d
h.u = a
h.q = g
a.o = l
assert j.o.q.o.u.o.q.txt == "a"