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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: D = None
        self.w: A = None
        self.u: B = None
        self.z: A = None
        self.txt = txt

n = A("n")
a = B("a")
e = C("e")
b = D("b")
f = E("f")
i = B("i")
k = A("k")
d = D("d")

n.r = k
n.p = i
a.y = e
e.p = i
b.q = a
f.p = i
f.v = b
f.w = k
f.z = k
f.u = a
i.y = e
k.r = n
k.p = a
d.q = a
assert e.p.y.p.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: D = None
        self.w: A = None
        self.u: B = None
        self.z: A = None
        self.txt = txt

n = A("n")
a = B("a")
e = C("e")
b = D("b")
f = E("f")
i = B("i")
k = A("k")
d = D("d")

n.r = k
n.p = i
a.y = e
e.p = i
b.q = a
f.p = i
f.v = b
f.w = k
f.z = k
f.u = a
i.y = e
k.r = n
k.p = a
d.q = a
assert e.p.y.p.y.p.txt == "i"