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

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

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

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

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

n = A("n")
f = B("f")
i = C("i")
g = D("g")
d = E("d")
b = D("b")
c = A("c")

n.q = d
n.u = c
n.r = c
f.o = b
i.p = f
i.u = f
i.x = g
g.s = n
g.z = i
d.r = c
d.z = f
d.q = g
d.p = b
d.t = i
b.s = n
b.z = i
c.q = d
c.u = n
c.r = n
assert d.q.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.u: A = None
        self.r: A = None
        self.txt = txt

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

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

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

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

n = A("n")
f = B("f")
i = C("i")
g = D("g")
d = E("d")
b = D("b")
c = A("c")

n.q = d
n.u = c
n.r = c
f.o = b
i.p = f
i.u = f
i.x = g
g.s = n
g.z = i
d.r = c
d.z = f
d.q = g
d.p = b
d.t = i
b.s = n
b.z = i
c.q = d
c.u = n
c.r = n
assert d.q.z.x.txt == "g"