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

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

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

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

j = A("j")
d = B("d")
a = C("a")
h = D("h")
k = D("k")
f = C("f")
n = A("n")
b = B("b")
m = C("m")

j.p = h
j.t = a
j.x = n
j.r = b
d.v = b
d.o = b
d.w = a
a.y = h
a.x = d
h.r = k
h.p = d
k.r = h
k.p = b
f.y = k
f.x = b
n.p = h
n.t = f
n.x = j
n.r = b
b.v = d
b.o = d
b.w = m
m.y = h
m.x = b
assert m.x.v.w.x.w.x.w.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.t: C = None
        self.x: A = None
        self.r: B = None
        self.txt = txt

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

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

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

j = A("j")
d = B("d")
a = C("a")
h = D("h")
k = D("k")
f = C("f")
n = A("n")
b = B("b")
m = C("m")

j.p = h
j.t = a
j.x = n
j.r = b
d.v = b
d.o = b
d.w = a
a.y = h
a.x = d
h.r = k
h.p = d
k.r = h
k.p = b
f.y = k
f.x = b
n.p = h
n.t = f
n.x = j
n.r = b
b.v = d
b.o = d
b.w = m
m.y = h
m.x = b
assert m.x.v.w.x.w.x.w.x.o.txt == "b"