class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: A = None
        self.o: D = None
        self.p: A = None
        self.txt = txt

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

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

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

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

c.u = l
c.s = l
c.p = l
c.o = j
n.w = l
n.q = b
f.o = h
b.r = h
b.o = h
b.t = h
j.r = h
j.t = h
j.o = n
k.o = h
l.u = c
l.s = c
l.o = j
l.p = e
e.u = c
e.s = l
e.p = l
e.o = j
h.w = e
h.q = j
assert c.p.s.o.o.q.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: A = None
        self.o: D = None
        self.p: A = None
        self.txt = txt

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

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

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

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

c.u = l
c.s = l
c.p = l
c.o = j
n.w = l
n.q = b
f.o = h
b.r = h
b.o = h
b.t = h
j.r = h
j.t = h
j.o = n
k.o = h
l.u = c
l.s = c
l.o = j
l.p = e
e.u = c
e.s = l
e.p = l
e.o = j
h.w = e
h.q = j
assert c.p.s.o.o.q.r.q.txt == "j"