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

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

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

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

b.q = f
b.y = f
b.r = m
c.u = i
c.v = i
c.r = h
g.w = d
g.r = c
g.s = i
h.q = f
h.r = b
h.y = g
f.w = a
f.r = i
f.s = c
i.u = c
i.v = c
i.r = m
d.w = f
d.r = c
d.s = c
m.q = d
m.y = d
m.r = h
a.w = f
a.r = i
a.s = c
assert m.y.w.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.r: A = None
        self.y: C = None
        self.txt = txt

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

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

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

b.q = f
b.y = f
b.r = m
c.u = i
c.v = i
c.r = h
g.w = d
g.r = c
g.s = i
h.q = f
h.r = b
h.y = g
f.w = a
f.r = i
f.s = c
i.u = c
i.v = c
i.r = m
d.w = f
d.r = c
d.s = c
m.q = d
m.y = d
m.r = h
a.w = f
a.r = i
a.s = c
assert m.y.w.r.r.r.txt == "h"