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

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

m = A("m")
d = B("d")
f = A("f")
n = A("n")
j = B("j")
g = A("g")
l = A("l")
i = A("i")

m.z = d
m.w = g
d.q = n
d.x = l
f.z = j
f.w = g
n.z = j
n.w = l
j.q = m
j.x = i
g.z = j
g.w = f
l.z = j
l.w = m
i.z = d
i.w = g
assert l.z.x.z.x.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: A = None
        self.txt = txt

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

m = A("m")
d = B("d")
f = A("f")
n = A("n")
j = B("j")
g = A("g")
l = A("l")
i = A("i")

m.z = d
m.w = g
d.q = n
d.x = l
f.z = j
f.w = g
n.z = j
n.w = l
j.q = m
j.x = i
g.z = j
g.w = f
l.z = j
l.w = m
i.z = d
i.w = g
assert l.z.x.z.x.w.w.w.txt == "f"