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

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: E = None
        self.w: E = None
        self.txt = txt

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

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

n.p = c
n.o = k
c.y = k
c.x = n
e.q = c
k.o = c
k.s = h
k.w = h
h.w = e
assert n.p.y.o.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: E = None
        self.w: E = None
        self.txt = txt

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

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

n.p = c
n.o = k
c.y = k
c.x = n
e.q = c
k.o = c
k.s = h
k.w = h
h.w = e
assert n.p.y.o.y.o.txt == "c"