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

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

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

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

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

l.v = g
l.s = b
f.w = l
g.y = c
c.x = g
c.s = g
c.w = f
c.v = l
b.v = g
b.s = l
assert f.w.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: A = None
        self.txt = txt

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

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

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

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

l.v = g
l.s = b
f.w = l
g.y = c
c.x = g
c.s = g
c.w = f
c.v = l
b.v = g
b.s = l
assert f.w.v.y.txt == "c"