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

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

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

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

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

c.o = j
c.q = i
l.z = n
l.x = a
n.w = a
k.t = c
k.y = l
k.u = l
i.o = b
i.q = h
d.o = i
d.q = j
a.w = n
b.o = c
b.q = h
h.o = j
h.q = b
j.o = b
j.q = d
assert i.o.o.o.q.o.o.o.o.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: A = None
        self.txt = txt

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

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

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

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

c.o = j
c.q = i
l.z = n
l.x = a
n.w = a
k.t = c
k.y = l
k.u = l
i.o = b
i.q = h
d.o = i
d.q = j
a.w = n
b.o = c
b.q = h
h.o = j
h.q = b
j.o = b
j.q = d
assert i.o.o.o.q.o.o.o.o.q.o.txt == "i"