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

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

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

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

l = A("l")
i = B("i")
d = C("d")
g = D("g")
h = D("h")

l.p = i
l.o = g
i.s = h
i.o = l
i.w = d
d.x = h
g.p = l
g.w = l
g.y = l
g.o = d
h.p = l
h.w = l
h.y = l
h.o = d
assert d.x.y.p.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: D = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
d = C("d")
g = D("g")
h = D("h")

l.p = i
l.o = g
i.s = h
i.o = l
i.w = d
d.x = h
g.p = l
g.w = l
g.y = l
g.o = d
h.p = l
h.w = l
h.y = l
h.o = d
assert d.x.y.p.s.w.txt == "l"