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

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

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

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

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

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

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

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

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

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

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