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

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

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

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

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

k = A("k")
i = B("i")
f = C("f")
d = D("d")
b = E("b")
g = B("g")

k.w = f
k.y = i
i.w = k
i.s = g
i.r = b
f.w = k
f.r = k
f.p = b
d.u = g
d.o = b
b.r = d
b.v = d
b.o = k
b.w = f
g.w = k
g.s = i
g.r = b
assert k.y.r.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: B = None
        self.txt = txt

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

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

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

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

k = A("k")
i = B("i")
f = C("f")
d = D("d")
b = E("b")
g = B("g")

k.w = f
k.y = i
i.w = k
i.s = g
i.r = b
f.w = k
f.r = k
f.p = b
d.u = g
d.o = b
b.r = d
b.v = d
b.o = k
b.w = f
g.w = k
g.s = i
g.r = b
assert k.y.r.w.p.txt == "b"