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

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

d = A("d")
e = B("e")
b = A("b")
m = B("m")
h = A("h")
j = A("j")
i = B("i")
a = A("a")
n = B("n")

d.s = j
d.q = j
e.z = h
e.w = d
b.s = j
b.q = a
m.z = a
m.w = d
h.s = b
h.q = d
j.s = a
j.q = b
i.z = a
i.w = b
a.s = d
a.q = b
n.z = a
n.w = j
assert j.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: A = None
        self.txt = txt

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

d = A("d")
e = B("e")
b = A("b")
m = B("m")
h = A("h")
j = A("j")
i = B("i")
a = A("a")
n = B("n")

d.s = j
d.q = j
e.z = h
e.w = d
b.s = j
b.q = a
m.z = a
m.w = d
h.s = b
h.q = d
j.s = a
j.q = b
i.z = a
i.w = b
a.s = d
a.q = b
n.z = a
n.w = j
assert j.q.q.q.q.txt == "a"