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

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

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

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

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

d.o = l
d.v = k
l.v = b
l.x = d
b.p = l
b.q = i
b.o = i
i.t = k
i.w = k
k.o = l
k.v = d
assert d.o.v.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.v: A = None
        self.txt = txt

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

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

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

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

d.o = l
d.v = k
l.v = b
l.x = d
b.p = l
b.q = i
b.o = i
i.t = k
i.w = k
k.o = l
k.v = d
assert d.o.v.p.x.txt == "d"