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

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

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

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

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

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

g.s = n
g.t = d
m.w = j
m.t = k
m.x = n
k.p = g
k.u = m
d.w = m
d.z = m
d.y = n
d.s = k
d.p = a
j.q = n
j.u = f
a.w = m
a.z = m
a.y = n
a.s = k
a.p = d
n.s = g
n.t = a
f.q = g
f.u = j
assert d.p.p.p.s.u.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: D = None
        self.txt = txt

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

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

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

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

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

g.s = n
g.t = d
m.w = j
m.t = k
m.x = n
k.p = g
k.u = m
d.w = m
d.z = m
d.y = n
d.s = k
d.p = a
j.q = n
j.u = f
a.w = m
a.z = m
a.y = n
a.s = k
a.p = d
n.s = g
n.t = a
f.q = g
f.u = j
assert d.p.p.p.s.u.t.p.txt == "g"