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

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

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

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

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

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

d.o = l
d.q = g
c.v = j
l.o = j
l.q = m
m.v = d
k.v = a
a.o = d
a.q = i
j.o = a
j.q = g
i.v = d
g.v = a
assert l.q.v.o.q.txt == "m"