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

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

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

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

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

j.u = m
k.z = a
k.p = j
k.q = c
k.y = m
n.y = a
c.o = k
c.s = k
m.z = n
m.p = j
m.q = c
m.y = k
l.o = k
l.s = m
a.y = n
assert k.y.y.q.o.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

j.u = m
k.z = a
k.p = j
k.q = c
k.y = m
n.y = a
c.o = k
c.s = k
m.z = n
m.p = j
m.q = c
m.y = k
l.o = k
l.s = m
a.y = n
assert k.y.y.q.o.y.y.txt == "k"