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

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

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

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

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

f = A("f")
n = B("n")
d = C("d")
c = D("c")
b = E("b")

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

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

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

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

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

f = A("f")
n = B("n")
d = C("d")
c = D("c")
b = E("b")

f.p = n
f.q = c
n.s = c
d.s = n
d.o = f
c.s = n
c.y = f
b.r = d
b.u = d
assert c.s.s.y.p.txt == "n"