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

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

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

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

i = A("i")
m = B("m")
g = C("g")
j = D("j")
n = A("n")
k = A("k")
h = D("h")
l = C("l")
a = C("a")

i.r = k
i.o = n
m.v = k
m.z = k
m.s = l
m.q = n
g.u = i
g.t = n
g.q = j
j.y = m
j.o = n
n.r = k
n.o = i
k.r = n
k.o = i
h.y = m
h.o = n
l.u = k
l.t = k
l.q = h
a.u = k
a.t = n
a.q = h
assert j.y.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: A = None
        self.txt = txt

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

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

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

i = A("i")
m = B("m")
g = C("g")
j = D("j")
n = A("n")
k = A("k")
h = D("h")
l = C("l")
a = C("a")

i.r = k
i.o = n
m.v = k
m.z = k
m.s = l
m.q = n
g.u = i
g.t = n
g.q = j
j.y = m
j.o = n
n.r = k
n.o = i
k.r = n
k.o = i
h.y = m
h.o = n
l.u = k
l.t = k
l.q = h
a.u = k
a.t = n
a.q = h
assert j.y.v.r.txt == "n"