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

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

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

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

a = A("a")
i = B("i")
f = C("f")
c = D("c")

a.w = f
a.r = f
a.x = i
i.u = c
f.o = a
f.w = a
f.s = i
f.v = c
c.u = f
c.x = i
assert i.u.u.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: B = None
        self.r: C = None
        self.txt = txt

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

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

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

a = A("a")
i = B("i")
f = C("f")
c = D("c")

a.w = f
a.r = f
a.x = i
i.u = c
f.o = a
f.w = a
f.s = i
f.v = c
c.u = f
c.x = i
assert i.u.u.v.u.txt == "f"