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

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

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

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

n = A("n")
f = B("f")
e = C("e")
h = D("h")
j = C("j")
b = C("b")

n.r = h
n.u = f
n.s = f
n.p = e
f.u = h
f.w = b
e.s = b
e.o = b
e.v = f
e.q = n
h.s = f
h.w = n
j.s = b
j.o = b
j.v = f
j.q = n
b.s = j
b.o = e
b.v = f
b.q = n
assert j.o.v.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: B = None
        self.p: C = None
        self.s: B = None
        self.txt = txt

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

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

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

n = A("n")
f = B("f")
e = C("e")
h = D("h")
j = C("j")
b = C("b")

n.r = h
n.u = f
n.s = f
n.p = e
f.u = h
f.w = b
e.s = b
e.o = b
e.v = f
e.q = n
h.s = f
h.w = n
j.s = b
j.o = b
j.v = f
j.q = n
b.s = j
b.o = e
b.v = f
b.q = n
assert j.o.v.u.w.txt == "n"