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

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

class C:
    def __init__(self, txt: str):
        self.t: E = None
        self.x: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

a = A("a")
c = B("c")
n = C("n")
d = D("d")
l = E("l")
i = E("i")
g = A("g")
m = A("m")
k = D("k")
f = C("f")

a.p = k
a.o = l
a.r = c
c.y = f
n.t = i
n.x = l
d.t = m
d.o = l
l.w = f
i.w = f
g.p = k
g.o = l
g.r = c
m.p = d
m.o = i
m.r = c
k.t = a
k.o = i
f.t = l
f.x = l
assert n.t.w.t.w.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.o: E = None
        self.r: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: E = None
        self.x: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

a = A("a")
c = B("c")
n = C("n")
d = D("d")
l = E("l")
i = E("i")
g = A("g")
m = A("m")
k = D("k")
f = C("f")

a.p = k
a.o = l
a.r = c
c.y = f
n.t = i
n.x = l
d.t = m
d.o = l
l.w = f
i.w = f
g.p = k
g.o = l
g.r = c
m.p = d
m.o = i
m.r = c
k.t = a
k.o = i
f.t = l
f.x = l
assert n.t.w.t.w.x.w.txt == "f"