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

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

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

j = A("j")
d = B("d")
g = C("g")
k = A("k")
h = C("h")
f = A("f")
b = C("b")
m = C("m")

j.r = k
j.x = d
d.u = m
g.s = b
g.p = m
g.u = d
k.r = f
k.x = d
h.s = m
h.p = m
h.u = d
f.r = k
f.x = d
b.s = m
b.p = h
b.u = d
m.s = g
m.p = g
m.u = d
assert g.u.u.s.p.s.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: B = None
        self.txt = txt

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

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

j = A("j")
d = B("d")
g = C("g")
k = A("k")
h = C("h")
f = A("f")
b = C("b")
m = C("m")

j.r = k
j.x = d
d.u = m
g.s = b
g.p = m
g.u = d
k.r = f
k.x = d
h.s = m
h.p = m
h.u = d
f.r = k
f.x = d
b.s = m
b.p = h
b.u = d
m.s = g
m.p = g
m.u = d
assert g.u.u.s.p.s.p.s.txt == "g"