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

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

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

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

a = A("a")
c = B("c")
d = C("d")
n = D("n")
e = A("e")
k = D("k")
j = A("j")
m = C("m")

a.w = n
a.u = n
c.v = m
d.v = c
d.x = c
d.z = m
d.p = m
n.y = d
n.u = k
n.w = a
n.s = j
e.w = k
e.u = n
k.y = m
k.u = n
k.w = a
k.s = a
j.w = k
j.u = k
m.v = c
m.x = c
m.z = d
m.p = d
assert j.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.u: D = None
        self.txt = txt

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

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

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

a = A("a")
c = B("c")
d = C("d")
n = D("n")
e = A("e")
k = D("k")
j = A("j")
m = C("m")

a.w = n
a.u = n
c.v = m
d.v = c
d.x = c
d.z = m
d.p = m
n.y = d
n.u = k
n.w = a
n.s = j
e.w = k
e.u = n
k.y = m
k.u = n
k.w = a
k.s = a
j.w = k
j.u = k
m.v = c
m.x = c
m.z = d
m.p = d
assert j.u.u.u.txt == "k"