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.u: A = None
        self.w: B = None
        self.txt = txt

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

m = A("m")
a = B("a")
j = C("j")
l = B("l")
h = A("h")

m.r = h
m.y = j
a.u = h
a.w = l
j.q = l
j.p = l
l.u = h
l.w = a
h.r = m
h.y = j
assert a.w.w.u.y.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.u: A = None
        self.w: B = None
        self.txt = txt

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

m = A("m")
a = B("a")
j = C("j")
l = B("l")
h = A("h")

m.r = h
m.y = j
a.u = h
a.w = l
j.q = l
j.p = l
l.u = h
l.w = a
h.r = m
h.y = j
assert a.w.w.u.y.txt == "j"