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

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

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

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

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

h.o = b
h.r = b
d.o = b
d.r = f
d.u = f
d.z = f
i.x = f
i.s = j
i.u = d
i.t = b
f.t = d
f.p = j
j.x = f
j.s = n
j.u = d
j.t = h
b.o = h
b.r = h
n.x = f
n.s = j
n.u = d
n.t = h
assert j.x.p.t.r.o.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: A = None
        self.txt = txt

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

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

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

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

h.o = b
h.r = b
d.o = b
d.r = f
d.u = f
d.z = f
i.x = f
i.s = j
i.u = d
i.t = b
f.t = d
f.p = j
j.x = f
j.s = n
j.u = d
j.t = h
b.o = h
b.r = h
n.x = f
n.s = j
n.u = d
n.t = h
assert j.x.p.t.r.o.r.o.txt == "h"