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

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

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

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

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

e.w = l
d.o = j
d.z = l
d.r = e
d.p = b
l.q = d
l.z = e
b.y = i
j.y = b
i.y = j
assert i.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

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

e.w = l
d.o = j
d.z = l
d.r = e
d.p = b
l.q = d
l.z = e
b.y = i
j.y = b
i.y = j
assert i.y.y.y.y.txt == "j"