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

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

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

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

k = A("k")
a = B("a")
g = C("g")
j = D("j")
i = A("i")
b = D("b")
e = B("e")

k.s = i
a.p = j
a.r = j
a.u = g
g.q = i
g.o = i
j.x = g
j.u = b
i.s = k
b.x = g
b.u = j
e.p = j
e.r = j
e.u = g
assert j.x.q.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

k = A("k")
a = B("a")
g = C("g")
j = D("j")
i = A("i")
b = D("b")
e = B("e")

k.s = i
a.p = j
a.r = j
a.u = g
g.q = i
g.o = i
j.x = g
j.u = b
i.s = k
b.x = g
b.u = j
e.p = j
e.r = j
e.u = g
assert j.x.q.s.s.s.s.s.txt == "k"