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

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

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

b = A("b")
e = B("e")
i = C("i")
h = C("h")
n = A("n")
g = B("g")
a = C("a")

b.s = a
b.v = g
b.r = g
e.t = g
e.r = h
e.z = i
i.w = b
h.w = b
n.s = h
n.v = g
n.r = g
g.t = e
g.r = h
g.z = i
a.w = n
assert n.v.r.w.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: B = None
        self.r: B = None
        self.txt = txt

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

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

b = A("b")
e = B("e")
i = C("i")
h = C("h")
n = A("n")
g = B("g")
a = C("a")

b.s = a
b.v = g
b.r = g
e.t = g
e.r = h
e.z = i
i.w = b
h.w = b
n.s = h
n.v = g
n.r = g
g.t = e
g.r = h
g.z = i
a.w = n
assert n.v.r.w.r.z.txt == "i"