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

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

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

f = A("f")
n = B("n")
a = C("a")
j = B("j")
i = A("i")
k = C("k")
g = A("g")

f.y = i
f.u = k
f.q = a
n.s = j
n.r = j
n.p = k
a.u = k
j.s = n
j.r = n
j.p = k
i.y = f
i.u = k
i.q = a
k.u = a
g.y = i
g.u = k
g.q = a
assert f.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: C = None
        self.q: C = None
        self.txt = txt

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

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

f = A("f")
n = B("n")
a = C("a")
j = B("j")
i = A("i")
k = C("k")
g = A("g")

f.y = i
f.u = k
f.q = a
n.s = j
n.r = j
n.p = k
a.u = k
j.s = n
j.r = n
j.p = k
i.y = f
i.u = k
i.q = a
k.u = a
g.y = i
g.u = k
g.q = a
assert f.y.y.y.y.y.txt == "i"