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

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

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

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

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

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

f.y = c
k.x = f
k.y = f
k.r = l
k.p = m
k.z = n
c.r = n
c.y = k
m.z = c
n.z = c
l.x = f
l.y = f
l.r = k
l.p = m
l.z = n
assert c.r.z.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

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

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

f.y = c
k.x = f
k.y = f
k.r = l
k.p = m
k.z = n
c.r = n
c.y = k
m.z = c
n.z = c
l.x = f
l.y = f
l.r = k
l.p = m
l.z = n
assert c.r.z.r.z.txt == "c"