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

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

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

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

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

j.o = m
j.q = n
c.q = j
k.s = e
k.q = d
k.p = d
d.o = b
m.q = j
e.q = j
b.s = c
b.q = d
b.p = n
h.q = j
n.o = k
assert n.o.q.o.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: D = None
        self.txt = txt

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

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

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

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

j.o = m
j.q = n
c.q = j
k.s = e
k.q = d
k.p = d
d.o = b
m.q = j
e.q = j
b.s = c
b.q = d
b.p = n
h.q = j
n.o = k
assert n.o.q.o.p.o.txt == "k"