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

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

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

n = A("n")
f = B("f")
j = C("j")
c = B("c")
h = B("h")
m = C("m")
b = C("b")
a = C("a")
g = A("g")

n.s = h
n.r = c
f.o = h
f.v = n
j.r = h
j.w = b
c.o = h
c.v = g
h.o = f
h.v = n
m.r = f
m.w = b
b.r = f
b.w = j
a.r = c
a.w = j
g.s = h
g.r = f
assert m.r.v.s.o.v.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: B = None
        self.txt = txt

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

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

n = A("n")
f = B("f")
j = C("j")
c = B("c")
h = B("h")
m = C("m")
b = C("b")
a = C("a")
g = A("g")

n.s = h
n.r = c
f.o = h
f.v = n
j.r = h
j.w = b
c.o = h
c.v = g
h.o = f
h.v = n
m.r = f
m.w = b
b.r = f
b.w = j
a.r = c
a.w = j
g.s = h
g.r = f
assert m.r.v.s.o.v.s.o.txt == "f"