class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.s: E = None
        self.q: D = None
        self.v: D = None
        self.x: C = None
        self.txt = txt

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

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

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

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

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

a.w = j
a.s = j
a.q = e
a.v = e
a.x = c
f.o = a
f.r = e
c.o = e
c.y = e
c.v = e
e.s = g
e.w = f
e.r = f
j.p = f
g.o = a
g.r = e
assert f.r.s.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.s: E = None
        self.q: D = None
        self.v: D = None
        self.x: C = None
        self.txt = txt

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

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

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

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

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

a.w = j
a.s = j
a.q = e
a.v = e
a.x = c
f.o = a
f.r = e
c.o = e
c.y = e
c.v = e
e.s = g
e.w = f
e.r = f
j.p = f
g.o = a
g.r = e
assert f.r.s.r.w.txt == "f"