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

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

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.t: B = None
        self.u: B = None
        self.r: D = None
        self.txt = txt

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.t: B = None
        self.u: B = None
        self.r: D = None
        self.txt = txt

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

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

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

b.w = k
b.p = f
k.z = f
k.u = f
k.s = d
d.q = e
d.t = k
d.u = k
d.r = i
i.o = d
e.s = k
e.x = f
f.w = k
f.p = b
a.o = d
assert d.q.x.p.txt == "b"