class A:
    def __init__(self, txt: str):
        self.r: B = 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.v: A = None
        self.s: A = None
        self.txt = txt

g = A("g")
d = B("d")
c = C("c")
f = A("f")
l = A("l")
a = C("a")
n = B("n")

g.r = n
d.w = l
c.v = g
c.s = g
f.r = n
l.r = d
a.v = l
a.s = f
n.w = f
assert n.w.r.w.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = 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.v: A = None
        self.s: A = None
        self.txt = txt

g = A("g")
d = B("d")
c = C("c")
f = A("f")
l = A("l")
a = C("a")
n = B("n")

g.r = n
d.w = l
c.v = g
c.s = g
f.r = n
l.r = d
a.v = l
a.s = f
n.w = f
assert n.w.r.w.r.w.r.txt == "n"