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

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: C = None
        self.q: C = None
        self.txt = txt

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

m = A("m")
j = B("j")
a = C("a")
h = D("h")
i = E("i")
l = F("l")
b = E("b")

m.y = l
m.s = j
m.v = j
j.x = h
j.s = a
a.r = m
h.r = m
i.w = a
i.v = a
i.q = a
l.w = a
b.w = a
b.v = a
b.q = a
assert h.r.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: F = None
        self.s: B = None
        self.v: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: C = None
        self.q: C = None
        self.txt = txt

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

m = A("m")
j = B("j")
a = C("a")
h = D("h")
i = E("i")
l = F("l")
b = E("b")

m.y = l
m.s = j
m.v = j
j.x = h
j.s = a
a.r = m
h.r = m
i.w = a
i.v = a
i.q = a
l.w = a
b.w = a
b.v = a
b.q = a
assert h.r.y.w.txt == "a"