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

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

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

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

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

n = A("n")
h = B("h")
g = C("g")
a = D("a")
l = E("l")
b = B("b")
j = C("j")
c = C("c")

n.v = l
n.q = a
h.x = n
g.o = n
g.w = h
a.z = h
a.o = n
l.s = h
l.p = h
l.w = b
l.o = a
b.x = n
j.o = n
j.w = h
c.o = n
c.w = h
assert h.x.q.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.q: D = None
        self.txt = txt

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

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

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

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

n = A("n")
h = B("h")
g = C("g")
a = D("a")
l = E("l")
b = B("b")
j = C("j")
c = C("c")

n.v = l
n.q = a
h.x = n
g.o = n
g.w = h
a.z = h
a.o = n
l.s = h
l.p = h
l.w = b
l.o = a
b.x = n
j.o = n
j.w = h
c.o = n
c.w = h
assert h.x.q.z.x.txt == "n"