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

b = A("b")
l = B("l")
i = B("i")
g = B("g")
j = A("j")
n = A("n")
f = B("f")
c = A("c")
h = A("h")
a = B("a")

b.w = i
l.q = h
i.q = j
g.q = h
j.w = g
n.w = f
f.q = h
c.w = f
h.w = i
a.q = b
assert a.q.w.q.w.q.w.q.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

b = A("b")
l = B("l")
i = B("i")
g = B("g")
j = A("j")
n = A("n")
f = B("f")
c = A("c")
h = A("h")
a = B("a")

b.w = i
l.q = h
i.q = j
g.q = h
j.w = g
n.w = f
f.q = h
c.w = f
h.w = i
a.q = b
assert a.q.w.q.w.q.w.q.txt == "j"