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

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

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

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

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

m = A("m")
l = B("l")
b = C("b")
k = D("k")
n = E("n")
f = C("f")

m.u = k
l.s = m
l.y = n
b.v = l
k.u = l
n.y = m
n.p = m
n.x = k
n.t = f
f.v = l
assert k.u.s.u.u.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

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

m = A("m")
l = B("l")
b = C("b")
k = D("k")
n = E("n")
f = C("f")

m.u = k
l.s = m
l.y = n
b.v = l
k.u = l
n.y = m
n.p = m
n.x = k
n.t = f
f.v = l
assert k.u.s.u.u.s.u.txt == "k"