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

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

b = A("b")
m = B("m")
k = C("k")
f = D("f")
e = D("e")
g = A("g")
j = B("j")
c = A("c")
l = B("l")

b.w = e
b.r = f
m.z = j
m.q = g
m.w = b
k.w = f
f.z = k
f.q = k
f.x = l
f.y = e
e.z = k
e.q = k
e.x = j
e.y = f
g.w = e
g.r = f
j.z = m
j.q = g
j.w = c
c.w = e
c.r = f
l.z = j
l.q = b
l.w = g
assert m.z.z.q.r.y.y.q.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.r: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

b = A("b")
m = B("m")
k = C("k")
f = D("f")
e = D("e")
g = A("g")
j = B("j")
c = A("c")
l = B("l")

b.w = e
b.r = f
m.z = j
m.q = g
m.w = b
k.w = f
f.z = k
f.q = k
f.x = l
f.y = e
e.z = k
e.q = k
e.x = j
e.y = f
g.w = e
g.r = f
j.z = m
j.q = g
j.w = c
c.w = e
c.r = f
l.z = j
l.q = b
l.w = g
assert m.z.z.q.r.y.y.q.w.z.txt == "k"