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

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

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

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

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

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

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

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

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

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

m.q = c
c.u = m
c.o = i
c.s = n
d.y = j
d.w = e
d.x = k
i.o = e
i.x = d
j.q = n
e.y = j
e.w = d
e.x = k
k.o = d
k.x = d
n.u = m
n.o = k
n.s = c
assert k.o.w.w.txt == "d"