class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.t: A = None
        self.x: A = None
        self.txt = txt

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

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

i = A("i")
e = B("e")
d = C("d")
c = D("c")

i.z = c
e.q = c
e.t = i
e.x = i
d.w = e
d.y = e
c.u = d
c.s = e
c.r = e
c.o = e
assert d.w.x.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.t: A = None
        self.x: A = None
        self.txt = txt

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

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

i = A("i")
e = B("e")
d = C("d")
c = D("c")

i.z = c
e.q = c
e.t = i
e.x = i
d.w = e
d.y = e
c.u = d
c.s = e
c.r = e
c.o = e
assert d.w.x.z.r.txt == "e"