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

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

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

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

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

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

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

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

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

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

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

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

n.p = c
n.r = k
n.t = f
c.q = f
f.s = n
k.w = n
k.u = h
k.p = c
h.o = f
h.y = f
h.u = n
h.p = n
assert k.p.q.s.p.q.txt == "f"