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

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

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

m = A("m")
k = B("k")
a = C("a")
b = B("b")
n = A("n")
f = C("f")
d = B("d")

m.y = n
m.r = f
m.x = d
k.s = m
k.w = m
k.v = b
a.w = n
b.s = n
b.w = n
b.v = k
n.y = m
n.r = a
n.x = d
f.w = m
d.s = n
d.w = n
d.v = b
assert f.w.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.r: C = None
        self.x: B = None
        self.txt = txt

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

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

m = A("m")
k = B("k")
a = C("a")
b = B("b")
n = A("n")
f = C("f")
d = B("d")

m.y = n
m.r = f
m.x = d
k.s = m
k.w = m
k.v = b
a.w = n
b.s = n
b.w = n
b.v = k
n.y = m
n.r = a
n.x = d
f.w = m
d.s = n
d.w = n
d.v = b
assert f.w.r.w.txt == "m"