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

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

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

f = A("f")
g = B("g")
n = C("n")
e = A("e")

f.v = g
f.r = n
f.x = n
g.r = n
g.x = n
g.s = n
n.z = f
e.v = g
e.r = n
e.x = n
assert f.v.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: C = None
        self.x: C = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
n = C("n")
e = A("e")

f.v = g
f.r = n
f.x = n
g.r = n
g.x = n
g.s = n
n.z = f
e.v = g
e.r = n
e.x = n
assert f.v.s.z.txt == "f"