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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

g.q = d
g.r = d
g.o = k
g.z = n
d.s = k
d.v = f
n.o = d
n.v = f
n.x = k
f.o = n
f.p = g
j.z = f
h.z = f
k.q = d
k.r = d
k.o = g
k.z = n
assert h.z.p.q.s.z.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: A = None
        self.z: C = None
        self.r: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

g.q = d
g.r = d
g.o = k
g.z = n
d.s = k
d.v = f
n.o = d
n.v = f
n.x = k
f.o = n
f.p = g
j.z = f
h.z = f
k.q = d
k.r = d
k.o = g
k.z = n
assert h.z.p.q.s.z.o.s.txt == "k"