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

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

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

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

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

c = A("c")
e = B("e")
b = C("b")
a = D("a")
f = E("f")
m = A("m")

c.o = b
e.q = m
b.o = e
b.p = c
b.u = m
a.r = e
f.u = b
f.p = b
f.r = m
m.o = b
assert a.r.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

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

c = A("c")
e = B("e")
b = C("b")
a = D("a")
f = E("f")
m = A("m")

c.o = b
e.q = m
b.o = e
b.p = c
b.u = m
a.r = e
f.u = b
f.p = b
f.r = m
m.o = b
assert a.r.q.o.txt == "b"