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

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

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

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

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

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

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

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

h.r = c
c.s = h
c.r = b
c.x = f
i.q = e
i.w = m
i.v = h
n.s = g
n.r = c
n.x = e
b.s = e
b.r = c
b.x = h
g.r = m
d.s = e
d.r = n
d.x = g
f.r = b
m.s = g
m.r = d
m.x = f
e.r = c
assert m.r.s.r.r.x.r.s.r.r.txt == "b"