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

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

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

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

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

n.q = h
n.s = a
c.r = h
h.p = b
h.v = c
h.o = e
j.t = a
j.v = k
l.r = b
d.r = h
b.p = h
b.v = k
b.o = e
k.r = b
e.r = h
a.q = h
a.s = n
assert a.q.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: A = None
        self.txt = txt

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

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

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

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

n.q = h
n.s = a
c.r = h
h.p = b
h.v = c
h.o = e
j.t = a
j.v = k
l.r = b
d.r = h
b.p = h
b.v = k
b.o = e
k.r = b
e.r = h
a.q = h
a.s = n
assert a.q.o.r.txt == "h"