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

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

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

d = A("d")
e = B("e")
n = C("n")
m = C("m")
c = A("c")
a = A("a")
b = A("b")
g = C("g")
h = B("h")

d.r = c
d.s = h
d.t = a
e.w = n
e.x = b
e.t = a
n.y = g
n.v = h
m.y = n
m.v = h
c.r = b
c.t = b
c.s = h
a.r = c
a.s = h
a.t = d
b.r = a
b.s = e
b.t = d
g.y = m
g.v = e
h.w = m
h.x = c
h.t = b
assert a.r.r.t.r.r.r.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: B = None
        self.t: A = None
        self.txt = txt

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

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

d = A("d")
e = B("e")
n = C("n")
m = C("m")
c = A("c")
a = A("a")
b = A("b")
g = C("g")
h = B("h")

d.r = c
d.s = h
d.t = a
e.w = n
e.x = b
e.t = a
n.y = g
n.v = h
m.y = n
m.v = h
c.r = b
c.t = b
c.s = h
a.r = c
a.s = h
a.t = d
b.r = a
b.s = e
b.t = d
g.y = m
g.v = e
h.w = m
h.x = c
h.t = b
assert a.r.r.t.r.r.r.t.s.txt == "h"