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

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

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

c = A("c")
l = B("l")
k = C("k")
a = B("a")
m = A("m")
n = C("n")
b = A("b")
j = A("j")

c.o = b
c.y = a
l.r = c
k.z = n
k.w = c
a.r = j
m.o = c
m.y = a
n.z = k
n.w = m
b.o = c
b.y = l
j.o = m
j.y = l
assert m.y.r.o.o.y.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: B = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
k = C("k")
a = B("a")
m = A("m")
n = C("n")
b = A("b")
j = A("j")

c.o = b
c.y = a
l.r = c
k.z = n
k.w = c
a.r = j
m.o = c
m.y = a
n.z = k
n.w = m
b.o = c
b.y = l
j.o = m
j.y = l
assert m.y.r.o.o.y.r.y.txt == "l"