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

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.s: A = None
        self.p: C = None
        self.q: D = None
        self.txt = txt

b = A("b")
k = B("k")
i = C("i")
d = D("d")
n = A("n")
j = B("j")
l = A("l")
g = D("g")
m = A("m")
c = C("c")

b.u = c
b.z = i
k.q = i
i.p = l
i.w = k
i.r = k
i.y = d
d.w = k
d.s = m
d.p = c
d.q = g
n.u = c
n.z = c
j.q = c
l.u = c
l.z = i
g.w = k
g.s = l
g.p = c
g.q = d
m.u = i
m.z = c
c.p = l
c.w = k
c.y = g
c.r = j
assert c.w.q.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.s: A = None
        self.p: C = None
        self.q: D = None
        self.txt = txt

b = A("b")
k = B("k")
i = C("i")
d = D("d")
n = A("n")
j = B("j")
l = A("l")
g = D("g")
m = A("m")
c = C("c")

b.u = c
b.z = i
k.q = i
i.p = l
i.w = k
i.r = k
i.y = d
d.w = k
d.s = m
d.p = c
d.q = g
n.u = c
n.z = c
j.q = c
l.u = c
l.z = i
g.w = k
g.s = l
g.p = c
g.q = d
m.u = i
m.z = c
c.p = l
c.w = k
c.y = g
c.r = j
assert c.w.q.p.u.txt == "c"