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

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

i = A("i")
b = B("b")
k = B("k")
d = A("d")
l = A("l")
g = B("g")
a = A("a")
f = B("f")
c = A("c")
n = A("n")

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

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

i = A("i")
b = B("b")
k = B("k")
d = A("d")
l = A("l")
g = B("g")
a = A("a")
f = B("f")
c = A("c")
n = A("n")

i.o = g
b.w = c
b.q = c
k.w = a
k.q = n
d.o = g
l.o = f
g.w = c
g.q = n
a.o = f
f.w = c
f.q = i
c.o = f
n.o = k
assert d.o.q.o.q.txt == "n"