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

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

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: B = None
        self.o: B = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: B = None
        self.o: B = None
        self.txt = txt

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

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

a.x = l
a.y = e
e.x = j
e.z = l
e.o = a
e.p = a
d.p = e
d.z = e
d.o = e
j.r = a
l.p = e
l.z = e
l.o = e
assert j.r.x.p.o.y.txt == "e"