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

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

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

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

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

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

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

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

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

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

n.s = c
n.q = c
b.r = h
k.u = l
k.v = n
k.x = c
l.o = b
l.x = h
l.s = c
l.p = c
h.o = b
h.x = l
h.s = n
h.p = n
c.s = n
c.q = n
f.u = h
f.v = n
f.x = n
assert b.r.x.p.q.s.s.txt == "n"