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

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

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.r: B = None
        self.q: D = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.r: B = None
        self.q: D = None
        self.txt = txt

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

b.s = e
e.y = h
e.p = h
e.x = i
e.q = d
h.q = c
d.t = h
d.r = e
d.q = c
k.t = h
k.r = e
k.q = d
l.s = e
i.s = e
m.t = h
m.r = e
m.q = c
c.t = h
c.r = e
c.q = m
assert m.r.x.s.q.t.txt == "h"