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

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

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

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

a = A("a")
m = B("m")
d = C("d")
j = D("j")
e = C("e")

a.y = m
a.r = d
m.r = d
m.v = e
m.o = a
m.y = a
d.t = a
d.p = a
d.s = a
d.x = j
j.o = d
j.t = d
e.t = a
e.p = a
e.s = a
e.x = j
assert m.o.r.s.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.r: C = None
        self.txt = txt

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

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

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

a = A("a")
m = B("m")
d = C("d")
j = D("j")
e = C("e")

a.y = m
a.r = d
m.r = d
m.v = e
m.o = a
m.y = a
d.t = a
d.p = a
d.s = a
d.x = j
j.o = d
j.t = d
e.t = a
e.p = a
e.s = a
e.x = j
assert m.o.r.s.y.y.txt == "a"