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

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

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

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

c = A("c")
k = B("k")
a = C("a")
l = D("l")
i = B("i")

c.x = l
k.p = c
a.p = c
l.o = a
l.v = a
l.w = c
l.y = i
i.p = c
assert i.p.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

c = A("c")
k = B("k")
a = C("a")
l = D("l")
i = B("i")

c.x = l
k.p = c
a.p = c
l.o = a
l.v = a
l.w = c
l.y = i
i.p = c
assert i.p.x.y.txt == "i"