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

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

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

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

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

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

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