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

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: B = None
        self.s: E = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
h = C("h")
d = D("d")
j = E("j")
n = A("n")
k = E("k")

a.o = n
c.z = h
c.q = h
c.o = n
c.w = n
c.x = k
h.q = c
h.v = c
h.s = k
d.s = n
j.o = d
j.v = d
j.u = c
j.z = c
j.s = k
n.o = a
k.o = d
k.v = d
k.u = c
k.z = c
k.s = j
assert k.u.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: B = None
        self.s: E = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
h = C("h")
d = D("d")
j = E("j")
n = A("n")
k = E("k")

a.o = n
c.z = h
c.q = h
c.o = n
c.w = n
c.x = k
h.q = c
h.v = c
h.s = k
d.s = n
j.o = d
j.v = d
j.u = c
j.z = c
j.s = k
n.o = a
k.o = d
k.v = d
k.u = c
k.z = c
k.s = j
assert k.u.x.s.txt == "j"