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

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

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

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

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

b = A("b")
e = B("e")
f = C("f")
j = D("j")
n = E("n")

b.r = f
e.y = f
e.z = f
e.r = f
e.w = n
f.r = n
f.o = j
j.r = e
j.x = e
j.t = e
j.o = n
n.q = e
assert f.o.o.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

b = A("b")
e = B("e")
f = C("f")
j = D("j")
n = E("n")

b.r = f
e.y = f
e.z = f
e.r = f
e.w = n
f.r = n
f.o = j
j.r = e
j.x = e
j.t = e
j.o = n
n.q = e
assert f.o.o.q.r.txt == "f"