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

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

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

d = A("d")
k = B("k")
g = C("g")
f = B("f")
n = C("n")
i = C("i")
h = A("h")

d.w = h
k.s = h
k.v = h
k.x = d
g.r = d
g.v = d
g.s = f
f.s = d
f.v = d
f.x = h
n.r = d
n.v = h
n.s = k
i.r = h
i.v = d
i.s = k
h.w = d
assert k.v.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

d = A("d")
k = B("k")
g = C("g")
f = B("f")
n = C("n")
i = C("i")
h = A("h")

d.w = h
k.s = h
k.v = h
k.x = d
g.r = d
g.v = d
g.s = f
f.s = d
f.v = d
f.x = h
n.r = d
n.v = h
n.s = k
i.r = h
i.v = d
i.s = k
h.w = d
assert k.v.w.w.w.w.w.w.txt == "h"