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

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

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

n = A("n")
e = B("e")
m = C("m")
d = C("d")
g = C("g")
j = B("j")

n.q = e
n.p = d
n.w = g
e.x = n
e.w = j
e.v = m
m.s = d
m.y = j
m.z = n
d.s = g
d.y = j
d.z = n
g.s = d
g.y = e
g.z = n
j.x = n
j.w = e
j.v = d
assert m.y.w.w.x.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: C = None
        self.w: C = None
        self.txt = txt

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

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

n = A("n")
e = B("e")
m = C("m")
d = C("d")
g = C("g")
j = B("j")

n.q = e
n.p = d
n.w = g
e.x = n
e.w = j
e.v = m
m.s = d
m.y = j
m.z = n
d.s = g
d.y = j
d.z = n
g.s = d
g.y = e
g.z = n
j.x = n
j.w = e
j.v = d
assert m.y.w.w.x.w.y.txt == "e"