class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.o: B = None
        self.z: E = None
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

b = A("b")
h = B("h")
e = C("e")
g = D("g")
k = E("k")
f = C("f")
n = B("n")
c = E("c")
l = C("l")
d = C("d")

b.p = d
b.o = h
b.z = k
b.q = g
h.w = c
h.x = b
e.q = n
e.x = n
e.r = l
e.z = h
g.r = h
k.p = b
f.q = h
f.x = h
f.r = l
f.z = n
n.w = c
n.x = b
c.p = b
l.q = h
l.x = h
l.r = e
l.z = n
d.q = h
d.z = h
d.r = f
d.x = n
assert n.w.p.o.x.q.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.o: B = None
        self.z: E = None
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

b = A("b")
h = B("h")
e = C("e")
g = D("g")
k = E("k")
f = C("f")
n = B("n")
c = E("c")
l = C("l")
d = C("d")

b.p = d
b.o = h
b.z = k
b.q = g
h.w = c
h.x = b
e.q = n
e.x = n
e.r = l
e.z = h
g.r = h
k.p = b
f.q = h
f.x = h
f.r = l
f.z = n
n.w = c
n.x = b
c.p = b
l.q = h
l.x = h
l.r = e
l.z = n
d.q = h
d.z = h
d.r = f
d.x = n
assert n.w.p.o.x.q.r.w.txt == "c"