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

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: C = None
        self.y: A = None
        self.z: E = None
        self.r: A = None
        self.txt = txt

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

c = A("c")
a = B("a")
f = C("f")
e = D("e")
n = E("n")
k = A("k")

c.p = f
a.o = k
a.q = e
f.y = e
e.p = a
e.o = f
e.y = c
e.r = c
e.z = n
n.p = f
k.p = f
assert c.p.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: C = None
        self.y: A = None
        self.z: E = None
        self.r: A = None
        self.txt = txt

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

c = A("c")
a = B("a")
f = C("f")
e = D("e")
n = E("n")
k = A("k")

c.p = f
a.o = k
a.q = e
f.y = e
e.p = a
e.o = f
e.y = c
e.r = c
e.z = n
n.p = f
k.p = f
assert c.p.y.r.txt == "c"