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

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

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

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

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

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

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

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

f.r = h
f.u = j
f.o = k
a.s = g
k.o = a
k.t = h
k.p = f
j.o = h
j.t = a
j.p = f
d.r = n
d.u = m
d.o = k
g.s = n
n.s = h
h.s = g
m.o = a
m.t = a
m.p = d
assert g.s.s.s.txt == "g"