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

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

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

l = A("l")
j = B("j")
h = C("h")
e = A("e")
f = C("f")
c = C("c")
g = B("g")

l.q = e
l.w = f
l.y = h
j.x = g
h.w = j
h.x = j
e.q = l
e.w = h
e.y = c
f.w = g
f.x = j
c.w = j
c.x = j
g.x = j
assert g.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: C = None
        self.y: C = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
h = C("h")
e = A("e")
f = C("f")
c = C("c")
g = B("g")

l.q = e
l.w = f
l.y = h
j.x = g
h.w = j
h.x = j
e.q = l
e.w = h
e.y = c
f.w = g
f.x = j
c.w = j
c.x = j
g.x = j
assert g.x.x.x.x.x.txt == "j"