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

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

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

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

l.y = h
l.p = j
l.w = c
a.p = c
a.y = h
a.q = h
j.q = c
j.v = c
h.q = c
h.v = c
c.y = h
c.p = j
c.w = l
assert h.q.p.v.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.w: A = None
        self.txt = txt

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

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

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

l.y = h
l.p = j
l.w = c
a.p = c
a.y = h
a.q = h
j.q = c
j.v = c
h.q = c
h.v = c
c.y = h
c.p = j
c.w = l
assert h.q.p.v.w.w.txt == "c"