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

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

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

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

a = A("a")
g = B("g")
j = C("j")
n = D("n")
d = A("d")
i = C("i")
m = D("m")
l = C("l")
f = D("f")
b = B("b")

a.y = f
g.o = b
g.p = m
g.r = a
j.w = b
n.z = m
n.w = m
n.t = l
n.q = b
d.y = f
i.w = b
m.z = n
m.w = n
m.t = i
m.q = g
l.w = g
f.z = m
f.t = j
f.q = b
f.w = n
b.o = g
b.p = m
b.r = a
assert d.y.q.p.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

a = A("a")
g = B("g")
j = C("j")
n = D("n")
d = A("d")
i = C("i")
m = D("m")
l = C("l")
f = D("f")
b = B("b")

a.y = f
g.o = b
g.p = m
g.r = a
j.w = b
n.z = m
n.w = m
n.t = l
n.q = b
d.y = f
i.w = b
m.z = n
m.w = n
m.t = i
m.q = g
l.w = g
f.z = m
f.t = j
f.q = b
f.w = n
b.o = g
b.p = m
b.r = a
assert d.y.q.p.t.w.txt == "b"