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

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

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

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

h = A("h")
l = B("l")
j = C("j")
b = D("b")
i = A("i")
f = B("f")
d = A("d")
g = B("g")
m = B("m")
k = C("k")

h.u = b
h.r = b
h.p = k
h.o = d
l.q = h
l.v = j
j.z = g
j.o = m
b.o = k
b.z = d
b.s = h
i.u = b
i.r = b
i.p = j
i.o = d
f.q = h
f.v = k
d.u = b
d.r = b
d.p = k
d.o = h
g.q = d
g.v = j
m.q = i
m.v = k
k.z = m
k.o = l
assert j.o.q.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: C = None
        self.r: D = None
        self.o: A = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
j = C("j")
b = D("b")
i = A("i")
f = B("f")
d = A("d")
g = B("g")
m = B("m")
k = C("k")

h.u = b
h.r = b
h.p = k
h.o = d
l.q = h
l.v = j
j.z = g
j.o = m
b.o = k
b.z = d
b.s = h
i.u = b
i.r = b
i.p = j
i.o = d
f.q = h
f.v = k
d.u = b
d.r = b
d.p = k
d.o = h
g.q = d
g.v = j
m.q = i
m.v = k
k.z = m
k.o = l
assert j.o.q.p.z.txt == "g"