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

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

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

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

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

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

m.u = n
c.x = n
c.u = m
n.p = k
n.o = m
b.v = m
k.u = c
k.r = n
k.t = n
assert k.u.x.p.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

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

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

m.u = n
c.x = n
c.u = m
n.p = k
n.o = m
b.v = m
k.u = c
k.r = n
k.t = n
assert k.u.x.p.u.u.txt == "m"