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

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

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

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

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

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

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

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

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

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

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