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

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

m = A("m")
i = B("i")
k = B("k")
c = A("c")
n = B("n")
b = B("b")
g = B("g")
j = B("j")
e = A("e")
l = A("l")

m.q = l
m.x = k
i.t = e
i.w = g
k.t = l
k.w = i
c.q = l
c.x = k
n.t = l
n.w = i
b.t = l
b.w = g
g.t = c
g.w = b
j.t = m
j.w = g
e.q = l
e.x = g
l.q = e
l.x = b
assert g.w.w.t.x.w.t.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: B = None
        self.txt = txt

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

m = A("m")
i = B("i")
k = B("k")
c = A("c")
n = B("n")
b = B("b")
g = B("g")
j = B("j")
e = A("e")
l = A("l")

m.q = l
m.x = k
i.t = e
i.w = g
k.t = l
k.w = i
c.q = l
c.x = k
n.t = l
n.w = i
b.t = l
b.w = g
g.t = c
g.w = b
j.t = m
j.w = g
e.q = l
e.x = g
l.q = e
l.x = b
assert g.w.w.t.x.w.t.x.w.txt == "b"