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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

j.u = n
k.u = n
c.z = n
n.o = k
n.s = c
n.p = j
d.q = b
d.y = n
d.r = n
b.q = d
b.y = n
b.r = n
assert k.u.s.z.s.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

j.u = n
k.u = n
c.z = n
n.o = k
n.s = c
n.p = j
d.q = b
d.y = n
d.r = n
b.q = d
b.y = n
b.r = n
assert k.u.s.z.s.z.p.txt == "j"