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

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

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

c = A("c")
j = B("j")
a = C("a")
e = C("e")
b = C("b")
l = A("l")
d = B("d")

c.y = j
c.v = j
j.r = d
a.s = j
a.w = e
e.s = j
e.w = a
b.s = d
b.w = a
l.y = d
l.v = j
d.r = j
assert c.y.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: B = None
        self.txt = txt

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

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

c = A("c")
j = B("j")
a = C("a")
e = C("e")
b = C("b")
l = A("l")
d = B("d")

c.y = j
c.v = j
j.r = d
a.s = j
a.w = e
e.s = j
e.w = a
b.s = d
b.w = a
l.y = d
l.v = j
d.r = j
assert c.y.r.r.r.r.r.txt == "d"