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

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

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

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

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

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

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

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

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

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

b.x = j
b.u = h
c.t = d
f.o = d
j.y = k
j.q = c
j.w = b
k.o = d
g.t = d
i.y = f
i.q = c
i.w = d
d.x = i
d.u = f
h.o = b
e.t = d
assert e.t.u.o.x.q.txt == "c"