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

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

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

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

d = A("d")
i = B("i")
m = C("m")
h = D("h")
e = A("e")
k = D("k")

d.s = i
d.r = i
d.v = i
d.w = e
i.q = e
m.s = e
m.p = k
m.y = h
h.q = m
h.x = m
h.v = e
h.w = k
e.s = i
e.r = i
e.v = i
e.w = d
k.q = m
k.x = m
k.v = e
k.w = h
assert i.q.r.q.w.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: B = None
        self.w: A = None
        self.v: B = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
m = C("m")
h = D("h")
e = A("e")
k = D("k")

d.s = i
d.r = i
d.v = i
d.w = e
i.q = e
m.s = e
m.p = k
m.y = h
h.q = m
h.x = m
h.v = e
h.w = k
e.s = i
e.r = i
e.v = i
e.w = d
k.q = m
k.x = m
k.v = e
k.w = h
assert i.q.r.q.w.s.q.txt == "e"