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

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

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

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

n = A("n")
e = B("e")
d = C("d")
g = D("g")
j = A("j")
k = A("k")
h = D("h")

n.r = k
n.s = j
n.w = h
n.v = d
e.o = d
e.t = j
d.u = h
d.p = h
g.o = d
g.s = k
g.z = j
g.u = e
j.r = n
j.s = k
j.w = g
j.v = d
k.r = j
k.s = n
k.w = h
k.v = d
h.o = d
h.s = j
h.z = n
h.u = e
assert h.o.u.u.o.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: A = None
        self.w: D = None
        self.v: C = None
        self.txt = txt

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

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

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

n = A("n")
e = B("e")
d = C("d")
g = D("g")
j = A("j")
k = A("k")
h = D("h")

n.r = k
n.s = j
n.w = h
n.v = d
e.o = d
e.t = j
d.u = h
d.p = h
g.o = d
g.s = k
g.z = j
g.u = e
j.r = n
j.s = k
j.w = g
j.v = d
k.r = j
k.s = n
k.w = h
k.v = d
h.o = d
h.s = j
h.z = n
h.u = e
assert h.o.u.u.o.u.o.txt == "d"