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

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

l = A("l")
n = B("n")
d = B("d")
b = A("b")
f = B("f")
c = A("c")
k = A("k")
m = B("m")

l.u = f
l.o = f
n.q = l
d.q = k
b.u = n
b.o = d
f.q = c
c.u = d
c.o = m
k.u = n
k.o = d
m.q = l
assert c.o.q.u.q.u.q.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: B = None
        self.txt = txt

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

l = A("l")
n = B("n")
d = B("d")
b = A("b")
f = B("f")
c = A("c")
k = A("k")
m = B("m")

l.u = f
l.o = f
n.q = l
d.q = k
b.u = n
b.o = d
f.q = c
c.u = d
c.o = m
k.u = n
k.o = d
m.q = l
assert c.o.q.u.q.u.q.o.q.txt == "k"