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

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

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

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

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

k.q = a
l.t = k
l.r = e
m.w = b
m.x = e
m.r = a
m.q = d
e.o = l
e.u = k
e.p = h
e.t = m
b.q = a
h.w = b
h.x = e
h.r = a
h.q = d
d.w = b
d.x = e
d.r = a
d.q = h
a.w = b
a.x = e
a.r = d
a.q = h
assert m.r.x.t.x.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

k.q = a
l.t = k
l.r = e
m.w = b
m.x = e
m.r = a
m.q = d
e.o = l
e.u = k
e.p = h
e.t = m
b.q = a
h.w = b
h.x = e
h.r = a
h.q = d
d.w = b
d.x = e
d.r = a
d.q = h
a.w = b
a.x = e
a.r = d
a.q = h
assert m.r.x.t.x.o.r.txt == "e"