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

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

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

k = A("k")
e = B("e")
c = C("c")
l = B("l")
b = B("b")
f = A("f")
j = C("j")

k.r = f
e.o = c
e.y = l
c.w = b
l.o = j
l.y = b
b.o = j
b.y = e
f.r = k
j.w = b
assert e.o.w.o.w.y.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

k = A("k")
e = B("e")
c = C("c")
l = B("l")
b = B("b")
f = A("f")
j = C("j")

k.r = f
e.o = c
e.y = l
c.w = b
l.o = j
l.y = b
b.o = j
b.y = e
f.r = k
j.w = b
assert e.o.w.o.w.y.o.w.txt == "b"