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

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

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

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

h = A("h")
l = B("l")
j = C("j")
a = D("a")
n = A("n")
b = B("b")
k = D("k")
i = C("i")
c = C("c")
e = A("e")

h.o = e
h.y = b
h.x = b
l.p = h
l.t = c
l.y = b
l.o = k
j.r = l
j.y = i
j.p = k
j.q = n
a.r = k
a.x = h
n.o = h
n.y = l
n.x = l
b.p = e
b.t = c
b.y = l
b.o = a
k.r = a
k.x = e
i.r = l
i.y = j
i.p = k
i.q = n
c.r = l
c.y = j
c.p = k
c.q = n
e.o = h
e.y = b
e.x = l
assert e.o.o.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: B = None
        self.x: B = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
j = C("j")
a = D("a")
n = A("n")
b = B("b")
k = D("k")
i = C("i")
c = C("c")
e = A("e")

h.o = e
h.y = b
h.x = b
l.p = h
l.t = c
l.y = b
l.o = k
j.r = l
j.y = i
j.p = k
j.q = n
a.r = k
a.x = h
n.o = h
n.y = l
n.x = l
b.p = e
b.t = c
b.y = l
b.o = a
k.r = a
k.x = e
i.r = l
i.y = j
i.p = k
i.q = n
c.r = l
c.y = j
c.p = k
c.q = n
e.o = h
e.y = b
e.x = l
assert e.o.o.x.o.txt == "k"