class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: C = None
        self.t: C = None
        self.p: B = None
        self.txt = txt

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

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

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

k = A("k")
g = B("g")
n = C("n")
a = D("a")
l = A("l")
b = C("b")

k.r = n
k.s = n
k.t = b
k.p = g
g.s = a
g.w = a
g.y = k
n.z = l
n.p = k
n.u = g
a.y = g
l.r = n
l.s = n
l.t = n
l.p = g
b.z = l
b.p = k
b.u = g
assert n.u.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: C = None
        self.t: C = None
        self.p: B = None
        self.txt = txt

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

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

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

k = A("k")
g = B("g")
n = C("n")
a = D("a")
l = A("l")
b = C("b")

k.r = n
k.s = n
k.t = b
k.p = g
g.s = a
g.w = a
g.y = k
n.z = l
n.p = k
n.u = g
a.y = g
l.r = n
l.s = n
l.t = n
l.p = g
b.z = l
b.p = k
b.u = g
assert n.u.w.y.txt == "g"