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

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

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

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

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

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

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

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

n.p = f
n.r = f
k.o = n
k.w = f
k.s = j
f.u = i
f.t = m
m.u = i
m.t = f
i.u = f
i.t = m
j.u = f
j.t = f
assert j.t.t.t.txt == "f"