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

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

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

b = A("b")
h = B("h")
n = C("n")
l = B("l")
g = C("g")
d = A("d")
a = A("a")
j = A("j")
m = C("m")
f = C("f")

b.q = h
h.s = g
h.z = a
h.y = j
n.t = f
n.u = h
n.p = h
l.s = g
l.z = a
l.y = d
g.t = f
g.u = h
g.p = h
d.q = l
a.q = h
j.q = l
m.t = n
m.u = l
m.p = h
f.t = n
f.u = l
f.p = h
assert j.q.z.q.s.p.y.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

b = A("b")
h = B("h")
n = C("n")
l = B("l")
g = C("g")
d = A("d")
a = A("a")
j = A("j")
m = C("m")
f = C("f")

b.q = h
h.s = g
h.z = a
h.y = j
n.t = f
n.u = h
n.p = h
l.s = g
l.z = a
l.y = d
g.t = f
g.u = h
g.p = h
d.q = l
a.q = h
j.q = l
m.t = n
m.u = l
m.p = h
f.t = n
f.u = l
f.p = h
assert j.q.z.q.s.p.y.q.y.txt == "d"