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

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

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

g = A("g")
f = B("f")
e = C("e")
l = B("l")
a = A("a")
n = B("n")
h = B("h")

g.s = e
g.w = e
f.r = a
e.v = n
l.r = a
a.s = e
a.w = e
n.r = a
h.r = a
assert g.w.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: C = None
        self.txt = txt

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

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

g = A("g")
f = B("f")
e = C("e")
l = B("l")
a = A("a")
n = B("n")
h = B("h")

g.s = e
g.w = e
f.r = a
e.v = n
l.r = a
a.s = e
a.w = e
n.r = a
h.r = a
assert g.w.v.r.txt == "a"