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

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

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

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

k = A("k")
g = B("g")
h = C("h")
l = D("l")
f = B("f")
m = B("m")

k.y = l
k.s = l
k.r = l
k.q = m
g.y = k
g.u = l
h.r = m
h.w = k
h.p = l
l.y = k
l.u = h
l.r = m
f.y = k
f.u = l
m.y = k
m.u = l
assert k.q.y.q.y.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.s: D = None
        self.q: B = None
        self.r: D = None
        self.txt = txt

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

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

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

k = A("k")
g = B("g")
h = C("h")
l = D("l")
f = B("f")
m = B("m")

k.y = l
k.s = l
k.r = l
k.q = m
g.y = k
g.u = l
h.r = m
h.w = k
h.p = l
l.y = k
l.u = h
l.r = m
f.y = k
f.u = l
m.y = k
m.u = l
assert k.q.y.q.y.s.r.txt == "m"