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

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: C = None
        self.p: C = None
        self.txt = txt

n = A("n")
c = B("c")
f = C("f")
i = A("i")
h = B("h")
m = A("m")
l = C("l")
e = A("e")
j = C("j")
g = A("g")

n.x = h
n.r = l
n.s = e
c.u = l
c.w = g
f.r = g
f.q = l
f.p = l
i.x = h
i.r = l
i.s = m
h.u = l
h.w = e
m.x = h
m.r = f
m.s = g
l.r = n
l.q = j
l.p = j
e.x = c
e.r = f
e.s = i
j.r = e
j.q = l
j.p = l
g.x = h
g.r = j
g.s = n
assert i.s.r.q.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: C = None
        self.s: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: C = None
        self.p: C = None
        self.txt = txt

n = A("n")
c = B("c")
f = C("f")
i = A("i")
h = B("h")
m = A("m")
l = C("l")
e = A("e")
j = C("j")
g = A("g")

n.x = h
n.r = l
n.s = e
c.u = l
c.w = g
f.r = g
f.q = l
f.p = l
i.x = h
i.r = l
i.s = m
h.u = l
h.w = e
m.x = h
m.r = f
m.s = g
l.r = n
l.q = j
l.p = j
e.x = c
e.r = f
e.s = i
j.r = e
j.q = l
j.p = l
g.x = h
g.r = j
g.s = n
assert i.s.r.q.r.r.txt == "l"