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

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

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

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

e = A("e")
l = B("l")
k = C("k")
b = D("b")

e.s = l
e.o = b
e.q = b
l.o = e
k.x = e
k.y = b
k.r = b
k.p = b
b.p = k
assert k.r.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: D = None
        self.q: D = None
        self.txt = txt

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

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

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

e = A("e")
l = B("l")
k = C("k")
b = D("b")

e.s = l
e.o = b
e.q = b
l.o = e
k.x = e
k.y = b
k.r = b
k.p = b
b.p = k
assert k.r.p.x.txt == "e"