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

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

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: A = None
        self.txt = txt

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

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

c.w = i
n.q = k
n.z = k
n.u = c
n.s = i
b.o = c
b.r = c
d.q = b
d.w = c
g.o = c
g.r = c
l.q = d
l.z = d
l.u = c
l.s = i
i.q = d
i.z = d
i.u = c
i.s = l
h.q = k
h.z = k
h.u = c
h.s = l
k.q = b
k.w = c
assert n.s.q.w.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: A = None
        self.txt = txt

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

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

c.w = i
n.q = k
n.z = k
n.u = c
n.s = i
b.o = c
b.r = c
d.q = b
d.w = c
g.o = c
g.r = c
l.q = d
l.z = d
l.u = c
l.s = i
i.q = d
i.z = d
i.u = c
i.s = l
h.q = k
h.z = k
h.u = c
h.s = l
k.q = b
k.w = c
assert n.s.q.w.w.z.txt == "d"