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

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

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

e = A("e")
h = B("h")
j = C("j")
a = A("a")
b = B("b")
c = A("c")
i = B("i")

e.q = h
e.u = a
h.y = a
j.r = h
j.w = h
j.x = c
a.q = i
a.u = c
b.y = a
c.q = i
c.u = a
i.y = a
assert c.q.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: A = None
        self.txt = txt

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

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

e = A("e")
h = B("h")
j = C("j")
a = A("a")
b = B("b")
c = A("c")
i = B("i")

e.q = h
e.u = a
h.y = a
j.r = h
j.w = h
j.x = c
a.q = i
a.u = c
b.y = a
c.q = i
c.u = a
i.y = a
assert c.q.y.u.txt == "c"