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

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

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

f = A("f")
j = B("j")
g = C("g")
e = A("e")
n = A("n")
m = A("m")
k = B("k")
c = C("c")

f.r = n
f.y = c
j.p = e
j.o = g
j.w = k
g.u = c
g.o = j
e.r = f
e.y = c
n.r = f
n.y = g
m.r = n
m.y = c
k.p = f
k.o = c
k.w = j
c.u = g
c.o = k
assert m.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: C = None
        self.txt = txt

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

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

f = A("f")
j = B("j")
g = C("g")
e = A("e")
n = A("n")
m = A("m")
k = B("k")
c = C("c")

f.r = n
f.y = c
j.p = e
j.o = g
j.w = k
g.u = c
g.o = j
e.r = f
e.y = c
n.r = f
n.y = g
m.r = n
m.y = c
k.p = f
k.o = c
k.w = j
c.u = g
c.o = k
assert m.r.r.r.r.txt == "f"