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

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: A = None
        self.s: A = None
        self.txt = txt

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

f = A("f")
d = B("d")
l = C("l")
i = D("i")

f.o = i
f.v = i
d.o = l
l.u = d
l.r = f
l.s = f
i.x = d
assert f.o.x.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.v: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: A = None
        self.s: A = None
        self.txt = txt

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

f = A("f")
d = B("d")
l = C("l")
i = D("i")

f.o = i
f.v = i
d.o = l
l.u = d
l.r = f
l.s = f
i.x = d
assert f.o.x.o.u.txt == "d"