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

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

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

c = A("c")
m = B("m")
n = C("n")
l = C("l")
a = C("a")
k = B("k")
d = A("d")
b = C("b")
f = A("f")

c.p = m
c.y = f
c.x = f
m.t = k
m.w = k
m.q = a
n.u = a
n.s = k
n.q = m
l.u = n
l.s = m
l.q = m
a.u = l
a.s = k
a.q = k
k.t = m
k.w = m
k.q = l
d.p = k
d.y = c
d.x = c
b.u = n
b.s = k
b.q = k
f.p = k
f.y = d
f.x = d
assert n.q.q.u.u.q.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: A = None
        self.x: A = None
        self.txt = txt

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

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

c = A("c")
m = B("m")
n = C("n")
l = C("l")
a = C("a")
k = B("k")
d = A("d")
b = C("b")
f = A("f")

c.p = m
c.y = f
c.x = f
m.t = k
m.w = k
m.q = a
n.u = a
n.s = k
n.q = m
l.u = n
l.s = m
l.q = m
a.u = l
a.s = k
a.q = k
k.t = m
k.w = m
k.q = l
d.p = k
d.y = c
d.x = c
b.u = n
b.s = k
b.q = k
f.p = k
f.y = d
f.x = d
assert n.q.q.u.u.q.t.w.txt == "m"