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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: A = None
        self.txt = txt

l = A("l")
h = B("h")
k = C("k")
a = D("a")
j = E("j")
b = E("b")

l.s = a
h.y = b
k.w = l
a.z = h
a.o = h
a.p = k
j.x = l
j.p = l
b.x = l
b.p = l
assert j.x.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: A = None
        self.txt = txt

l = A("l")
h = B("h")
k = C("k")
a = D("a")
j = E("j")
b = E("b")

l.s = a
h.y = b
k.w = l
a.z = h
a.o = h
a.p = k
j.x = l
j.p = l
b.x = l
b.p = l
assert j.x.s.p.txt == "k"