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

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

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

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

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

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

d.q = f
d.t = a
e.w = f
e.p = d
e.u = a
e.z = c
f.w = e
f.r = e
f.y = e
f.v = d
c.y = f
a.o = d
a.t = e
assert f.y.z.y.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.t: E = None
        self.txt = txt

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

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

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

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

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

d.q = f
d.t = a
e.w = f
e.p = d
e.u = a
e.z = c
f.w = e
f.r = e
f.y = e
f.v = d
c.y = f
a.o = d
a.t = e
assert f.y.z.y.r.w.txt == "f"