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

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

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: B = None
        self.txt = txt

e = A("e")
i = B("i")
j = C("j")
d = C("d")
f = B("f")
k = A("k")
n = B("n")
c = B("c")
m = A("m")
l = A("l")

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

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

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: B = None
        self.txt = txt

e = A("e")
i = B("i")
j = C("j")
d = C("d")
f = B("f")
k = A("k")
n = B("n")
c = B("c")
m = A("m")
l = A("l")

e.w = m
e.x = l
i.u = e
i.z = m
i.q = j
j.y = d
j.x = f
d.y = j
d.x = i
f.u = l
f.z = l
f.q = d
k.w = m
k.x = e
n.u = k
n.z = m
n.q = d
c.u = k
c.z = m
c.q = j
m.w = l
m.x = k
l.w = e
l.x = e
assert k.x.w.x.x.w.w.txt == "l"