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

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

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

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

c = A("c")
j = B("j")
a = C("a")
f = D("f")
i = A("i")
g = A("g")
d = A("d")

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

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

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

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

c = A("c")
j = B("j")
a = C("a")
f = D("f")
i = A("i")
g = A("g")
d = A("d")

c.y = i
c.q = f
c.v = a
j.q = f
j.z = f
j.w = a
a.t = j
a.o = j
f.q = g
i.y = c
i.q = f
i.v = a
g.y = d
g.q = f
g.v = a
d.y = g
d.q = f
d.v = a
assert a.o.z.q.y.txt == "d"