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

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

a = A("a")
e = B("e")
m = A("m")
g = A("g")
h = A("h")
b = A("b")
d = B("d")
l = A("l")
k = A("k")
j = A("j")

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

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

a = A("a")
e = B("e")
m = A("m")
g = A("g")
h = A("h")
b = A("b")
d = B("d")
l = A("l")
k = A("k")
j = A("j")

a.q = d
a.u = l
e.w = d
m.q = d
m.u = l
g.q = e
g.u = h
h.q = e
h.u = l
b.q = e
b.u = h
d.w = e
l.q = d
l.u = b
k.q = d
k.u = a
j.q = d
j.u = l
assert d.w.w.w.w.w.w.w.w.txt == "d"