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

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: B = None
        self.s: D = None
        self.u: C = None
        self.txt = txt

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

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

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

n = A("n")
k = B("k")
c = C("c")
g = D("g")
m = E("m")
j = B("j")

n.u = c
n.t = k
k.q = n
k.w = j
k.s = g
k.u = c
c.x = g
g.u = m
g.o = k
m.p = n
j.q = n
j.w = k
j.s = g
j.u = c
assert m.p.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: B = None
        self.s: D = None
        self.u: C = None
        self.txt = txt

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

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

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

n = A("n")
k = B("k")
c = C("c")
g = D("g")
m = E("m")
j = B("j")

n.u = c
n.t = k
k.q = n
k.w = j
k.s = g
k.u = c
c.x = g
g.u = m
g.o = k
m.p = n
j.q = n
j.w = k
j.s = g
j.u = c
assert m.p.u.x.txt == "g"