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

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

j = A("j")
n = B("n")
k = A("k")
h = B("h")
b = B("b")
m = B("m")
l = A("l")
f = A("f")
d = B("d")
g = B("g")

j.w = d
n.q = k
k.w = g
h.q = f
b.q = f
m.q = k
l.w = d
f.w = d
d.q = l
g.q = f
assert h.q.w.q.w.q.w.q.w.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

j = A("j")
n = B("n")
k = A("k")
h = B("h")
b = B("b")
m = B("m")
l = A("l")
f = A("f")
d = B("d")
g = B("g")

j.w = d
n.q = k
k.w = g
h.q = f
b.q = f
m.q = k
l.w = d
f.w = d
d.q = l
g.q = f
assert h.q.w.q.w.q.w.q.w.q.w.txt == "d"