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

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

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

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

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

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

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

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

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

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

a.y = c
a.w = c
a.q = j
f.z = e
f.o = d
f.y = g
i.y = h
c.u = h
c.o = e
j.y = a
e.y = c
e.w = c
e.q = j
d.y = a
g.z = a
g.o = i
g.y = f
h.y = c
h.w = c
h.q = d
assert a.y.u.w.o.y.o.q.txt == "j"