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

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

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

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

a = A("a")
g = B("g")
f = C("f")
l = D("l")

a.o = l
a.u = l
a.x = l
g.v = l
f.v = a
f.z = g
l.r = f
l.o = f
l.p = a
assert l.p.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.u: D = None
        self.x: D = None
        self.txt = txt

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

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

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

a = A("a")
g = B("g")
f = C("f")
l = D("l")

a.o = l
a.u = l
a.x = l
g.v = l
f.v = a
f.z = g
l.r = f
l.o = f
l.p = a
assert l.p.x.r.txt == "f"