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

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

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

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

f = A("f")
i = B("i")
l = C("l")
c = D("c")
g = B("g")

f.y = c
f.r = c
f.v = l
i.s = l
l.p = c
l.o = c
l.v = f
c.z = l
c.q = f
g.s = l
assert i.s.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.r: D = None
        self.v: C = None
        self.txt = txt

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

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

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

f = A("f")
i = B("i")
l = C("l")
c = D("c")
g = B("g")

f.y = c
f.r = c
f.v = l
i.s = l
l.p = c
l.o = c
l.v = f
c.z = l
c.q = f
g.s = l
assert i.s.v.v.v.txt == "f"