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

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

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

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

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

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

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

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

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

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

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

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

j.y = c
j.u = h
h.p = k
c.t = j
c.u = j
c.p = k
n.q = k
n.x = k
n.u = c
n.s = h
k.u = j
assert h.p.u.y.p.u.txt == "j"