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

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

d = A("d")
m = B("m")
e = B("e")
c = A("c")
h = B("h")
j = A("j")
l = B("l")
k = B("k")
a = A("a")
i = A("i")

d.z = l
d.w = e
m.q = h
m.y = c
e.q = m
e.y = j
c.z = m
c.w = m
h.q = k
h.y = d
j.z = h
j.w = e
l.q = e
l.y = i
k.q = m
k.y = a
a.z = l
a.w = h
i.z = m
i.w = l
assert k.q.q.q.q.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: B = None
        self.txt = txt

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

d = A("d")
m = B("m")
e = B("e")
c = A("c")
h = B("h")
j = A("j")
l = B("l")
k = B("k")
a = A("a")
i = A("i")

d.z = l
d.w = e
m.q = h
m.y = c
e.q = m
e.y = j
c.z = m
c.w = m
h.q = k
h.y = d
j.z = h
j.w = e
l.q = e
l.y = i
k.q = m
k.y = a
a.z = l
a.w = h
i.z = m
i.w = l
assert k.q.q.q.q.q.y.txt == "d"