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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.z: C = None
        self.w: A = None
        self.x: A = None
        self.o: B = None
        self.txt = txt

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

f.r = b
b.o = g
b.u = f
e.q = f
e.s = g
e.z = g
j.p = e
j.r = e
j.s = b
g.u = f
g.w = f
g.x = f
g.z = e
g.o = b
assert j.p.s.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.z: C = None
        self.w: A = None
        self.x: A = None
        self.o: B = None
        self.txt = txt

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

f.r = b
b.o = g
b.u = f
e.q = f
e.s = g
e.z = g
j.p = e
j.r = e
j.s = b
g.u = f
g.w = f
g.x = f
g.z = e
g.o = b
assert j.p.s.u.r.u.txt == "f"